-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
stats/opentelemetry: enable otel dial option to pass empty MetricOptions{} #7952
base: master
Are you sure you want to change the base?
Conversation
f88438e
to
f2a9f2a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7952 +/- ##
==========================================
+ Coverage 82.09% 82.17% +0.08%
==========================================
Files 379 381 +2
Lines 38261 38558 +297
==========================================
+ Hits 31409 31686 +277
- Misses 5549 5570 +21
+ Partials 1303 1302 -1
|
if h.options.MetricsOptions.MeterProvider == nil { | ||
return | ||
} |
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 think the only changes needed may be to set the metrics and the MetricsProvider to no-op versions, rest of the changes can be reverted.
if h.options.MetricsOptions.MeterProvider == nil { | |
return | |
} | |
if h.options.MetricsOptions.MeterProvider == nil { | |
h.clientMetrics.attemptStarted = noop.Int64Counter{} | |
h.clientMetrics.attemptDuration = noop.Float64Histogram{} | |
h.clientMetrics.attemptSentTotalCompressedMessageSize = noop.Int64Histogram{} | |
h.clientMetrics.attemptRcvdTotalCompressedMessageSize = noop.Int64Histogram{} | |
h.clientMetrics.callDuration = noop.Float64Histogram{} | |
h.MetricsRecorder = ®istryMetrics{} | |
return | |
} |
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.
If we set the metrics
in setClientMetrics
to an empty set using stats.NewMetricSet()
, we end up getting no-op implementations for the clientMetrics and registryMetrics
. We can use this fact to unify the code paths for MeterProvider == nil
and MeterProvider != nil
.
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.
@arjan-bal I have updated the PR with suggested change above. Could you clarify this comment?
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.
With the current approach, the list of metrics (attemptStarted, attemptDuration, attemptSentTotalCompressedMessageSize etc.) is duplicated. If we set metrics
to an empty set using stats.NewMetricSet()
, the existing code will set every metric to the corresponding noop
histogram, avoiding duplication.
This PR addresses the issue where users cannot pass empty MetricOptions in the gRPC-Go OpenTelemetry implementation, leading to runtime errors. This allows user to pass empty MetricOptions which enhances flexibility for users who want to disable metrics collection without a full configuration.
Changes Made
RELEASE NOTES: