Skip to content
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

[🍒 7444] OpenTelemetry drop-in fixes for r2dbc #7445

Merged
merged 5 commits into from
Aug 15, 2024
Merged
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
6 changes: 5 additions & 1 deletion dd-java-agent/agent-otel/otel-bootstrap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ shadowJar {
exclude 'io/opentelemetry/context/internal/shaded/**'
include 'io/opentelemetry/semconv/**'
include 'io/opentelemetry/instrumentation/api/**'
exclude 'io/opentelemetry/instrumentation/api/incubator/**'
exclude 'io/opentelemetry/instrumentation/api/incubator/log/**'
exclude 'io/opentelemetry/instrumentation/api/incubator/semconv/db/*Sanitizer*'
exclude 'io/opentelemetry/instrumentation/api/incubator/semconv/http/**'
exclude 'io/opentelemetry/instrumentation/api/incubator/semconv/messaging/**'
exclude 'io/opentelemetry/instrumentation/api/incubator/semconv/rpc/**'
exclude 'io/opentelemetry/instrumentation/api/internal/cache/**'
exclude 'io/opentelemetry/instrumentation/api/internal/RuntimeVirtualFieldSupplier*'
exclude 'io/opentelemetry/instrumentation/api/util/VirtualField*'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package datadog.trace.bootstrap.otel.instrumentation.api.incubator.semconv.db;

/** Simple holder of sanitized statements. */
public final class SqlStatementInfo {

private final String statement;
private final String operation;
private final String table;

public static SqlStatementInfo create(String statement, String operation, String table) {
return null;
}

private SqlStatementInfo(String statement, String operation, String table) {
this.statement = statement;
this.operation = operation;
this.table = table;
}

public String getFullStatement() {
return statement;
}

public String getOperation() {
return operation;
}

public String getMainIdentifier() {
return table;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package datadog.trace.bootstrap.otel.instrumentation.api.incubator.semconv.db;

import datadog.trace.bootstrap.instrumentation.jdbc.DBQueryInfo;

/** Redirects requests to our own {@link DBQueryInfo} sanitizer. */
public final class SqlStatementSanitizer {

public static SqlStatementSanitizer create(boolean sanitizationEnabled) {
return new SqlStatementSanitizer(sanitizationEnabled);
}

private final boolean sanitizationEnabled;

private SqlStatementSanitizer(boolean sanitizationEnabled) {
this.sanitizationEnabled = sanitizationEnabled;
}

public SqlStatementInfo sanitize(String statement) {
if (sanitizationEnabled) {
DBQueryInfo dbQueryInfo = DBQueryInfo.ofPreparedStatement(statement);
return SqlStatementInfo.create(
dbQueryInfo.getSql().toString(), dbQueryInfo.getOperation().toString(), null);
} else {
return SqlStatementInfo.create(statement, null, null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ static final class Renamer extends Remapper {
RENAMED_TYPES.put(
"io/opentelemetry/javaagent/tooling/muzzle/references/Source",
Type.getInternalName(OtelMuzzleRefBuilder.Source.class));
RENAMED_TYPES.put(
"io/opentelemetry/instrumentation/CallDepth",
"datadog/trace/bootstrap/otel/instrumentation/CallDepth");
RENAMED_TYPES.put(
"io/opentelemetry/instrumentation/Java8BytecodeBridge",
"datadog/trace/bootstrap/otel/instrumentation/Java8BytecodeBridge");
}

/** OpenTelemetry and related packages shaded inside the tracer. */
Expand All @@ -120,7 +126,18 @@ static final class Renamer extends Remapper {
RENAMED_PACKAGES.put("io/opentelemetry/semconv/", "datadog/trace/bootstrap/otel/semconv/");

RENAMED_PACKAGES.put(
"io/opentelemetry/instrumentation/", "datadog/trace/bootstrap/otel/instrumentation/");
"io/opentelemetry/instrumentation/api/",
"datadog/trace/bootstrap/otel/instrumentation/api/");
RENAMED_PACKAGES.put(
"io/opentelemetry/instrumentation/http/",
"datadog/trace/bootstrap/otel/instrumentation/http/");
RENAMED_PACKAGES.put(
"io/opentelemetry/instrumentation/servlet/",
"datadog/trace/bootstrap/otel/instrumentation/servlet/");
RENAMED_PACKAGES.put(
"io/opentelemetry/instrumentation/internal/",
"datadog/trace/bootstrap/otel/instrumentation/internal/");

RENAMED_PACKAGES.put(
"io/opentelemetry/javaagent/bootstrap/", "datadog/trace/bootstrap/otel/instrumentation/");

Expand Down