Skip to content
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

Merged
merged 2 commits into from
May 21, 2024

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

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 using RegisterCallback 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.

@Quinn-With-Two-Ns Quinn-With-Two-Ns marked this pull request as ready for review May 21, 2024 14:18
@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner May 21, 2024 14:18
Comment on lines +7 to +9
go.opentelemetry.io/otel v1.23.0
go.opentelemetry.io/otel/sdk v1.23.0
go.opentelemetry.io/otel/trace v1.23.0
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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.

Copy link
Contributor Author

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

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 222d4cf into temporalio:master May 21, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants