-
Notifications
You must be signed in to change notification settings - Fork 173
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
OTEL tweaks #428
OTEL tweaks #428
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #428 +/- ##
==========================================
- Coverage 96.00% 95.96% -0.05%
==========================================
Files 77 77
Lines 32392 32403 +11
==========================================
- Hits 31099 31095 -4
- Misses 1103 1113 +10
- Partials 190 195 +5 ☔ View full report in Codecov by Sentry. |
Hi @ash2k,
Thank you for the reference. Good to know this fun fact.
Totally agreed. I forgot to mark |
Done! |
Thanks @ash2k! |
First commit: it's good to avoid mutable public fields because they encourage poor user behavior. It's possible to configure the histogram buckets via options, no need to make the default value mutable.
Second commit: it's better to fail early if OTEL library returned an error rather than discard an error, store
nil
in the field and then panic with NPE later. There will be no way to find out why the field wasnil
because the error was discarded. Also, it'd be better ifWithClient()
just returned an error.Third commit:
Second()
does something weird instead of just division. It loses precision that way. OpenTelementry libraries just use division, e.g. https://github.com/open-telemetry/opentelemetry-go-contrib/blob/8e44cea6d4fe181343500b6cb680bd501b3d24aa/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go#L343-L344Overall I think it's not the best choice to have both
WithClient()
andNewClient()
. Why not have a single function and let the user configure if they want metrics, traces, both, and with what options. If we want to keep two functions, names are really not clear. They should beWithTracing()
andWithMetrics()
or something like that.But IMO it's better to have a single function. If someone doesn't want e.g. metrics, they can provide a NOOP
MeterProvider
. Same with tracing - there is a NOOPTracerProvider
.