-
Notifications
You must be signed in to change notification settings - Fork 872
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
Allow JDBC autoinstrumentation to use a custom OpenTelemetry instance to be more DI (e.g. Spring Boot) friendly #7697
Conversation
|
*/ | ||
public OpenTelemetryDataSource(DataSource delegate) { | ||
public OpenTelemetryDataSource(DataSource delegate, OpenTelemetry openTelemetry) { |
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.
👍🏽 👍🏽 👍🏽 👍🏽 👍🏽 👍🏽 👍🏽 👍🏽 👍🏽
...dbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/jdbc/datasource/OpenTelemetryDataSource.java
Show resolved
Hide resolved
@FranPregernik looks like your commits authored under a different id from your GitHub id, and the EasyCLA check can't verify if you've signed the CLA because of this. Can you set the author field to your GH id and rebase? |
Propagates a custom OpenTelemetry instance through the datasource, connection and statement(s) wrappers. The OpenTelemetryDriver uses an OpenTelemetry instance provided by the GlobalOpenTelemetry.get() static method.
...ry/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/OpenTelemetryConnection.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java
Outdated
Show resolved
Hide resolved
...ry/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/OpenTelemetryStatement.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/jdbc/datasource/OpenTelemetryDataSource.java
Outdated
Show resolved
Hide resolved
@@ -46,7 +48,8 @@ public static void start( | |||
return; | |||
} | |||
|
|||
context = instrumenter().start(parentContext, ds); |
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.
Oh, it turns out the javaagent instrumentation was using the library singletons class. Can you add a dataSourceInstrumenter()
method to the JdbcSingletons
class? You should be able to reuse the DataSourceInstrumenterFactory
class you've just added.
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.
Are you sure about JdbcSingletons
? Because It has been renamed to JdbcInstrumenterFactory.
I added it for now to the DataSourceInstrumentation
class but I can move it to the JdbcSingletons class.
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.
Yep - the javaagent instrumentation has its own, separate JdbcSingletons
class.
By convention, we always create static methods for each instrumenter - usually it's just instrumenter()
, but in this case, since we have >1 instrumenter here it'd be dataSourceInstrumenter()
.../javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java
Show resolved
Hide resolved
.../javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java
Outdated
Show resolved
Hide resolved
.../javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java
Outdated
Show resolved
Hide resolved
public static Instrumenter<DbRequest, Void> instrumenter() { | ||
return INSTRUMENTER; | ||
} | ||
public static final Instrumenter<DbRequest, Void> STATEMENT_INSTRUMENTER = |
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.
The other comment about JdbcSingletons
was about the javaagent JdbcSingletons
class (yeah, we have multiple classes with the same name in this project 😅 ); this one should be safe to remove.
.../javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java
Show resolved
Hide resolved
...ary/src/test/groovy/io/opentelemetry/instrumentation/jdbc/OpenTelemetryConnectionTest.groovy
Outdated
Show resolved
Hide resolved
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.
LGTM 👍
Thanks for bearing with all my comments @FranPregernik !
Thank you for guiding me. One tidbit of info... seems I am not the only one who needed this. https://stackoverflow.com/questions/75293292/spring-micrometer-opentelemetry-exporter-otlp |
Related to issue #7677