use extended opentelemetry
This commit is contained in:
parent
eb8720f491
commit
a8325cb902
|
|
@ -65,3 +65,10 @@ tasks {
|
||||||
jvmArgs("-Dotel.instrumentation.jdbc.experimental.transaction.enabled=true")
|
jvmArgs("-Dotel.instrumentation.jdbc.experimental.transaction.enabled=true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo remove when the next release is published
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy {
|
||||||
|
force("io.opentelemetry:opentelemetry-api-incubator:1.53.0-alpha-SNAPSHOT")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,13 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.jdbc.internal;
|
package io.opentelemetry.instrumentation.jdbc.internal;
|
||||||
|
|
||||||
|
import static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties.empty;
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.api.incubator.ExtendedOpenTelemetry;
|
||||||
|
import io.opentelemetry.api.incubator.config.ConfigProvider;
|
||||||
|
import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientMetrics;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientMetrics;
|
||||||
|
|
@ -48,11 +52,30 @@ public final class JdbcInstrumenterFactory {
|
||||||
openTelemetry,
|
openTelemetry,
|
||||||
emptyList(),
|
emptyList(),
|
||||||
true,
|
true,
|
||||||
ConfigPropertiesUtil.getBoolean(
|
isStatementSanitizationEnabled(openTelemetry),
|
||||||
"otel.instrumentation.common.db-statement-sanitizer.enabled", true),
|
|
||||||
captureQueryParameters);
|
captureQueryParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isStatementSanitizationEnabled(OpenTelemetry openTelemetry) {
|
||||||
|
if (openTelemetry instanceof ExtendedOpenTelemetry) {
|
||||||
|
ConfigProvider configProvider = ((ExtendedOpenTelemetry) openTelemetry).getConfigProvider();
|
||||||
|
// we might want to pull the config bridge to instrumentation-api-incubator which we can
|
||||||
|
// use here
|
||||||
|
DeclarativeConfigProperties properties = configProvider.getInstrumentationConfig();
|
||||||
|
if (properties == null) {
|
||||||
|
properties = DeclarativeConfigProperties.empty();
|
||||||
|
}
|
||||||
|
return properties
|
||||||
|
.getStructured("java", empty())
|
||||||
|
.getStructured("common", empty())
|
||||||
|
.getStructured("db_statement_sanitizer", empty())
|
||||||
|
.getBoolean("enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConfigPropertiesUtil.getBoolean(
|
||||||
|
"otel.instrumentation.common.db-statement-sanitizer.enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
public static Instrumenter<DbRequest, Void> createStatementInstrumenter(
|
public static Instrumenter<DbRequest, Void> createStatementInstrumenter(
|
||||||
OpenTelemetry openTelemetry,
|
OpenTelemetry openTelemetry,
|
||||||
boolean enabled,
|
boolean enabled,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue