-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Histogram sum is not correct in latest version (critical) #3284
Comments
I am not able to reproduce this behavior with the following code. Please provide a complete example of your usage that can be run to reproduce the bug and the commit hash of the package you are running against.
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/sdk/metric"
)
func main() {
ctx := context.Background()
// The exporter embeds a default OpenTelemetry Reader and
// implements prometheus.Collector, allowing it to be used as
// both a Reader and Collector.
exporter, err := prometheus.New()
if err != nil {
log.Fatal(err)
}
provider := metric.NewMeterProvider(metric.WithReader(exporter))
meter := provider.Meter("github.com/open-telemetry/opentelemetry-go/example/prometheus")
// Start the prometheus HTTP server and pass the exporter Collector to it
go serveMetrics()
// This is the equivalent of prometheus.NewHistogramVec
histogram, err := meter.SyncInt64().Histogram("enp_offering_eoffr_http_client_total_duration")
if err != nil {
log.Fatal(err)
}
histogram.Record(ctx, 23, attribute.String("to_service", "catalog"))
histogram.Record(ctx, 187, attribute.String("to_service", "ordering"))
ctx, _ = signal.NotifyContext(ctx, os.Interrupt)
<-ctx.Done()
}
func serveMetrics() {
log.Printf("serving metrics at localhost:2223/metrics")
http.Handle("/metrics", promhttp.Handler())
err := http.ListenAndServe(":2223", nil)
if err != nil {
fmt.Printf("error serving http: %v", err)
return
}
}
go 1.18
require (
github.com/prometheus/client_golang v1.13.0
go.opentelemetry.io/otel v1.11.0
go.opentelemetry.io/otel/exporters/prometheus v0.32.3
go.opentelemetry.io/otel/sdk/metric v0.32.3
)
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
go.opentelemetry.io/otel/metric v0.32.3 // indirect
go.opentelemetry.io/otel/sdk v1.11.0 // indirect
go.opentelemetry.io/otel/trace v1.11.0 // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
replace go.opentelemetry.io/otel => ../..
replace go.opentelemetry.io/otel/exporters/prometheus => ../../exporters/prometheus
replace go.opentelemetry.io/otel/sdk => ../../sdk
replace go.opentelemetry.io/otel/sdk/metric => ../../sdk/metric
replace go.opentelemetry.io/otel/metric => ../../metric
replace go.opentelemetry.io/otel/trace => ../../trace Project version: b6a22ab Running the above:
and in another terminal:
|
I make repo for bug:
|
This looks specific to the otlpmetric exporters. The histogram sum is a pointer that is not recreated for every iteration of the export transform loop:
Therefore the last one iterated over is use for all. |
Fixes open-telemetry#3284 The transform uses the same reference a histogram datapoint sum value for all transformed metrics. This results in all transformed metrics being exported with the same sum (see open-telemetry#3284). This changes the transform to correctly reference a unique sum for each datapoint.
Hello, @MrAlias!) Can you tell me when the release of version 0.33.0 is planned? Our team is looking forward to the release) |
* Fix HistogramDataPoints transform in otlpmetric Fixes #3284 The transform uses the same reference a histogram datapoint sum value for all transformed metrics. This results in all transformed metrics being exported with the same sum (see #3284). This changes the transform to correctly reference a unique sum for each datapoint.
@krupyansky you can track the release progress here: https://github.com/open-telemetry/opentelemetry-go/milestone/31 |
Description
On localhost:8889/metrics I get the data:
# HELP enp_offering_eoffr_http_client_total_duration
# TYPE enp_offering_eoffr_http_client_total_duration histogram
enp_offering_eoffr_http_client_total_duration_sum{http_flavor="HTTP/1.1",http_method="POST",http_status_code="200",instance="23d4c8be87b8",job="enp-offering",to_service="catalog"} 2557
enp_offering_eoffr_http_client_total_duration_sum{http_flavor="HTTP/1.1",http_method="POST",http_status_code="200",instance="23d4c8be87b8",job="enp-offering",to_service="ordering"} 2557
I have one histogram with different values for key "to_service": catalog and ordering.
And I get always the same value for different buckets.
Also, values of sum for both buckets do not increase.
This bug is not reproduced in previous versions.
Environment
Steps To Reproduce
Expected behavior
Expect correct values for sum
The text was updated successfully, but these errors were encountered: