-
Notifications
You must be signed in to change notification settings - Fork 220
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
Fix gauge metrics with latest otel SDK #1482
Fix gauge metrics with latest otel SDK #1482
Conversation
go.opentelemetry.io/otel v1.23.0 | ||
go.opentelemetry.io/otel/sdk v1.23.0 | ||
go.opentelemetry.io/otel/trace v1.23.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume 1.23 instead of 1.26 just because we want lowest-working version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was the lowest version that our old implementation broke on
@@ -130,12 +130,20 @@ func (m MetricsHandler) Counter(name string) client.MetricsCounter { | |||
func (m MetricsHandler) Gauge(name string) client.MetricsGauge { | |||
// TODO(https://github.com/open-telemetry/opentelemetry-go/issues/3984) replace with sync gauge once supported | |||
var config atomic.Value | |||
config.Store(0.0) | |||
_, err := m.meter.Float64ObservableGauge(name, | |||
metric.WithFloat64Callback(func(ctx context.Context, o metric.Float64Observer) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrmm, were you able to dig up what changed on their side for why this callback doesn't work for us anymore? I am just curious, if not no worries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to find what exact commit broke it unfortunately
31a554d
to
2e0549b
Compare
2e0549b
to
61d67c4
Compare
As reported here there appears to be a change in behaviour in Go OTEL SDK library when creating multiple gauges with the same name. Now only the first callbacks registered callback is used and all others are ignored. This causes some metrics to be missing. To work around this until
SyncGauge
is released in the Go SDK I switched to usingRegisterCallback
as these callbacks are still called.While working in this area I also made it so gauges don't emit zero if no value has been reported.