-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow JDBC autoinstrumentation to use a custom OpenTelemetry instance…
- Loading branch information
1 parent
c3e8770
commit 1d3752f
Showing
16 changed files
with
218 additions
and
138 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
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
32 changes: 32 additions & 0 deletions
32
...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,32 @@ | ||
/* | ||
* 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> createDataSourceInstrumenter( | ||
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.
47 changes: 47 additions & 0 deletions
47
...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,47 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jdbc.internal; | ||
|
||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
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> createStatementInstrumenter() { | ||
return createStatementInstrumenter(GlobalOpenTelemetry.get()); | ||
} | ||
|
||
public static Instrumenter<DbRequest, Void> createStatementInstrumenter( | ||
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() {} | ||
} |
Oops, something went wrong.