Skip to content

use extended opentelemetry #14251

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions instrumentation/jdbc/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ tasks {
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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

package io.opentelemetry.instrumentation.jdbc.internal;

import static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties.empty;
import static java.util.Collections.emptyList;

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.CodeSpanNameExtractor;
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientMetrics;
Expand Down Expand Up @@ -48,11 +52,30 @@ static Instrumenter<DbRequest, Void> createStatementInstrumenter(
openTelemetry,
emptyList(),
true,
ConfigPropertiesUtil.getBoolean(
"otel.instrumentation.common.db-statement-sanitizer.enabled", true),
isStatementSanitizationEnabled(openTelemetry),
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(
OpenTelemetry openTelemetry,
boolean enabled,
Expand Down
Loading