Skip to content

Commit

Permalink
fix: use gauge for server.uptime metric (#1510)
Browse files Browse the repository at this point in the history
Co-authored-by: Ludwig <ludwig.bedacht@gmail.com>
  • Loading branch information
StarpTech and Noroth authored Jan 14, 2025
1 parent e6f4b9b commit 77a16d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions router-tests/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2605,15 +2605,13 @@ func TestRuntimeTelemetry(t *testing.T) {

metricServerUptime := getMetricByName(runtimeScope, "server.uptime")
require.NotNil(t, metricServerUptime)
metricServerUptimeDataType := metricServerUptime.Data.(metricdata.Sum[int64])
metricServerUptimeDataType := metricServerUptime.Data.(metricdata.Gauge[int64])
require.Len(t, metricServerUptimeDataType.DataPoints, 1)
serverUptimeMetric := metricdata.Metrics{
Name: "server.uptime",
Description: "Seconds since the server started. Resets between router config changes.",
Unit: "s",
Data: metricdata.Sum[int64]{
Temporality: metricdata.CumulativeTemporality,
IsMonotonic: true,
Data: metricdata.Gauge[int64]{
DataPoints: []metricdata.DataPoint[int64]{
{
Attributes: attribute.NewSet(
Expand Down
2 changes: 1 addition & 1 deletion router/pkg/metric/router_runtime_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (r *RuntimeMetrics) Start() error {
return err
}

serverUptime, err := r.meter.Int64ObservableCounter(
serverUptime, err := r.meter.Int64ObservableGauge(
"server.uptime",
otelmetric.WithUnit("s"),
otelmetric.WithDescription("Seconds since the server started. Resets between router config changes."),
Expand Down

0 comments on commit 77a16d2

Please sign in to comment.