Skip to content

Commit fa7d331

Browse files
committed
document why we check for existing span on command listener
1 parent d2a91cc commit fa7d331

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

dd-java-agent/instrumentation/mongo/common/src/main/java/datadog/trace/instrumentation/mongo/MongoCommandListener.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ public void commandStarted(final CommandStartedEvent event) {
124124
if (listenerAccessor != null) {
125125
listenerAccessor.putIfAbsent(event.getConnectionDescription(), this);
126126
}
127+
128+
// If DBM comment injection is enabled, the span is created on the connection instrumentation
129+
// this is required because the comment injection needs to happen before the command is sent
127130
AgentSpan span = activeSpan();
128131
boolean shouldForceCloseSpanScope = true;
129132
if (span == null || span.getSpanName() != MongoDecorator.OPERATION_NAME) {

0 commit comments

Comments
 (0)