Skip to content

Commit e3d43d5

Browse files
Merge pull request #7849 from DataDog/nenadnoveljic/dbm-trace-injected-sqlserver
Add DBM_TRACE_INJECTED tag to SQL Server
2 parents a7982c2 + 74e7b48 commit e3d43d5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

dd-java-agent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ public static AgentScope onEnter(
103103
if (span != null && INJECT_COMMENT) {
104104
String traceParent = null;
105105

106-
if (injectTraceContext && !isSqlServer) {
106+
if (injectTraceContext) {
107107
Integer priority = span.forceSamplingDecision();
108108
if (priority != null) {
109-
traceParent = DECORATE.traceParent(span, priority);
109+
if (!isSqlServer) {
110+
traceParent = DECORATE.traceParent(span, priority);
111+
}
110112
// set the dbm trace injected tag on the span
111113
span.setTag(DBM_TRACE_INJECTED, true);
112114
}

dd-java-agent/instrumentation/jdbc/src/test/groovy/RemoteJDBCInstrumentationTest.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ abstract class RemoteJDBCInstrumentationTest extends VersionedNamingTestBase {
277277
if (usingHikari) {
278278
"$Tags.DB_POOL_NAME" String
279279
}
280+
if (addDbmTag) {
281+
"$InstrumentationTags.DBM_TRACE_INJECTED" true
282+
}
280283
peerServiceFrom(Tags.DB_INSTANCE)
281284
defaultTags()
282285
}
@@ -765,6 +768,9 @@ abstract class RemoteJDBCInstrumentationTest extends VersionedNamingTestBase {
765768
// since Connection.getClientInfo will not provide the username
766769
"$Tags.DB_USER" { it == null || it == jdbcUserNames.get(driver) }
767770
"${Tags.DB_OPERATION}" operation
771+
if (addDbmTag) {
772+
"$InstrumentationTags.DBM_TRACE_INJECTED" true
773+
}
768774
if (conPoolType == "hikari") {
769775
"$Tags.DB_POOL_NAME" String
770776
}

0 commit comments

Comments
 (0)