You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Asynchronous, adding instruments (e.g., SumObserver) are used to capture sums directly. This means, for example, that in any sequence of SumObserver observations for a given instrument and label set, the Last Value defines the sum of the instrument.
The comment on Int64SumObserver claims:
// Int64SumObserver is a metric that captures a precomputed sum of// int64 values at a point in time.
I expect that calling Int64SumObserver.Observe(v) only returns the latest observation instead of a sum of all observations.
Actual Behavior
Int64SumObserver sums up all observations instead of using the last value.
This makes it impossible to define Prometheus COUNTERs from external sources.
I found this bug when trying to export a counter in Redis.
Code Example
package example
import (
"context""net/http""net/http/httptest""net/url""testing""time""github.com/stretchr/testify/require""go.opentelemetry.io/otel""go.opentelemetry.io/otel/exporters/metric/prometheus""go.opentelemetry.io/otel/metric"
)
funcTestSums(t*testing.T) {
// Install new Prometheus exporterexporter, err:=prometheus.InstallNewPipeline(prometheus.Config{})
require.NoError(t, err)
// Define a sum observer that always sees "100"._, err=otel.Meter("test").NewInt64SumObserver("test_sum", func(ctx context.Context, result metric.Int64ObserverResult) {
result.Observe(100)
})
require.NoError(t, err)
// Send some requestsreq:=&http.Request{
Method: "GET",
URL: &url.URL{
Scheme: "http",
Host: "localhost",
Path: "/metrics",
},
}
exporter.ServeHTTP(httptest.NewRecorder(), req)
time.Sleep(15*time.Second)
exporter.ServeHTTP(httptest.NewRecorder(), req)
time.Sleep(15*time.Second)
exporter.ServeHTTP(httptest.NewRecorder(), req)
time.Sleep(15*time.Second)
// Print last requestrecorder:=httptest.NewRecorder()
exporter.ServeHTTP(recorder, req)
body:=recorder.Body.String()
t.Log("Exported Metrics\n"+body)
}
Outputs
# HELP test_sum
# TYPE test_sum counter
test_sum 400
The text was updated successfully, but these errors were encountered:
otel version: v0.14.0
Expected behavior
The OpenTelemetry specification claims:
The comment on Int64SumObserver claims:
I expect that calling
Int64SumObserver.Observe(v)
only returns the latest observation instead of a sum of all observations.Actual Behavior
Int64SumObserver
sums up all observations instead of using the last value.This makes it impossible to define Prometheus
COUNTER
s from external sources.I found this bug when trying to export a counter in Redis.
Code Example
Outputs
The text was updated successfully, but these errors were encountered: