-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: add OpenTelemetry tracing #1182
Conversation
Adds OpenTelemetry tracing and metrics, and configures Google Cloud Trace and Google Cloud Monitoring exports.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## postgresql-dialect #1182 +/- ##
========================================================
- Coverage 90.53% 89.95% -0.58%
- Complexity 2561 2587 +26
========================================================
Files 141 141
Lines 8652 8874 +222
Branches 1263 1285 +22
========================================================
+ Hits 7833 7983 +150
- Misses 557 622 +65
- Partials 262 269 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Can you please link me to the guide you used for Otel integration?
It looks very different from https://opentelemetry.io/docs/instrumentation/java/manual/
|
||
In addition, PGAdapter always adds an exporter for Google Cloud Trace. | ||
|
||
## Traces |
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.
Can you please add examples for metrics also here?
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.
We don't add any metrics in this pull request, only traces.
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.
Alright sounds good then. Thanks!
server.startServer(); | ||
} catch (Exception e) { | ||
printError(e, System.err, System.out); | ||
} | ||
} | ||
|
||
static OpenTelemetry setupOpenTelemetry(OptionsMetadata optionsMetadata) throws IOException { | ||
if (!optionsMetadata.isEnableOpenTelemetry()) { | ||
return OpenTelemetry.noop(); |
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.
Why is this noop?
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.
Returning a noop
OpenTelemetry instance instead of null when OpenTelemetry has not been enabled makes the rest of the code simpler, as we don't need null checks everywhere.
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.
Thanks!
@@ -218,6 +222,20 @@ public Builder setRequireAuthentication() { | |||
return this; | |||
} | |||
|
|||
/** Enables OpenTelemetry tracing for PGAdapter. */ | |||
public Builder setEnableOpenTelemetry() { |
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.
We are planning to make the Otel metrics in the client library as opt-in by default. So i think we should make this also as opt-out.
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.
What exactly do you mean by opt-in by default
. Does that mean that you will enable it by default? If so, what exactly do you mean with enabled by default?
- Does it mean 'we enable OpenTelemetry by default, but we don't by default add any exporters'? If so, I would argue that this is still the same as the feature being an opt-in, as you still need to add an exporter before you actually collect any metrics.
- Or does it mean that we enable both OpenTelemetry and add an exporter (e.g. Google Cloud Tracer) by default? That would mean that we by default enable a feature that could incur additional costs for the customer. Is that intentional?
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 meant the latter. But I realize now that itsn not possible for traces as we cannot specify a namespace. So lets leave this as-is. Thank you!
This setup uses the OpenTelemetry automatic configuration module: https://opentelemetry.io/docs/instrumentation/java/manual/#automatic-configuration The reason for this is that PGAdapter is mostly used as a standalone application, and not as a library. That means that configuration must happen on the command line when starting the application, instead of programmatic configuration that would be logical in a library (e.g. the Java client). The reasoning here is:
|
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.
Otel integration LGTM. Thanks a lot!
Adds
OpenTelemetry
tracing and configures Google Cloud Trace exports.