-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom (non-global) OpenTelemetry instance propagation
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.
- Loading branch information
1 parent
79a644d
commit a33abc7
Showing
13 changed files
with
175 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...in/java/io/opentelemetry/instrumentation/jdbc/internal/DataSourceInstrumenterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jdbc.internal; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.instrumentation.api.instrumenter.code.CodeAttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor; | ||
import javax.sql.DataSource; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public final class DataSourceInstrumenterFactory { | ||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; | ||
private static final DataSourceCodeAttributesGetter codeAttributesGetter = | ||
new DataSourceCodeAttributesGetter(); | ||
|
||
public static Instrumenter<DataSource, Void> createInstrumenter(OpenTelemetry openTelemetry) { | ||
return Instrumenter.<DataSource, Void>builder( | ||
openTelemetry, INSTRUMENTATION_NAME, CodeSpanNameExtractor.create(codeAttributesGetter)) | ||
.addAttributesExtractor(CodeAttributesExtractor.create(codeAttributesGetter)) | ||
.buildInstrumenter(); | ||
} | ||
|
||
private DataSourceInstrumenterFactory() {} | ||
} |
40 changes: 0 additions & 40 deletions
40
...ry/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DataSourceSingletons.java
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jdbc.internal; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.db.SqlClientAttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public final class JdbcInstrumenterFactory { | ||
public static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; | ||
private static final JdbcAttributesGetter dbAttributesGetter = new JdbcAttributesGetter(); | ||
private static final JdbcNetAttributesGetter netAttributesGetter = new JdbcNetAttributesGetter(); | ||
|
||
public static Instrumenter<DbRequest, Void> createInstrumenter() { | ||
return createInstrumenter(null); | ||
} | ||
|
||
public static Instrumenter<DbRequest, Void> createInstrumenter(OpenTelemetry openTelemetry) { | ||
return Instrumenter.<DbRequest, Void>builder( | ||
openTelemetry, | ||
INSTRUMENTATION_NAME, | ||
DbClientSpanNameExtractor.create(dbAttributesGetter)) | ||
.addAttributesExtractor( | ||
SqlClientAttributesExtractor.builder(dbAttributesGetter) | ||
.setStatementSanitizationEnabled( | ||
ConfigPropertiesUtil.getBoolean( | ||
"otel.instrumentation.common.db-statement-sanitizer.enabled", true)) | ||
.build()) | ||
.addAttributesExtractor(NetClientAttributesExtractor.create(netAttributesGetter)) | ||
.buildInstrumenter(SpanKindExtractor.alwaysClient()); | ||
} | ||
|
||
private JdbcInstrumenterFactory() {} | ||
} |
49 changes: 0 additions & 49 deletions
49
.../library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.