Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class JMSMessageConsumerInstrumentation
implements Instrumenter.ForTypeHierarchy, Instrumenter.HasMethodAdvice {
Expand Down Expand Up @@ -164,6 +166,7 @@ public static void afterReceive(
CONSUMER_DECORATE.onError(span, throwable);

activateNext(span); // scope is left open until next message or it times out
JMSLogger.logIterationSpan(span);

SessionState sessionState = consumerState.getSessionState();
if (sessionState.isClientAcknowledge()) {
Expand Down Expand Up @@ -213,4 +216,12 @@ public static void setMessageListener(
}
}
}

public static class JMSLogger {
private static final Logger log = LoggerFactory.getLogger(JMSLogger.class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why we need a separate static class here and static function for 1 debug message...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because you can't have "static field" in advice. So anything static, for caching for example, should go to an helper.
But my question is how is that even work if the JMSLogger is not registered as an helper 🤔


public static void logIterationSpan(AgentSpan span) {
log.debug("Expecting the following `ITERATION` span to be finished {}", span);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog.trace.core.scopemanager;

import static datadog.trace.api.ConfigDefaults.DEFAULT_ASYNC_PROPAGATING;
import static datadog.trace.api.telemetry.LogCollector.SEND_TELEMETRY;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopScope;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopSpan;
import static datadog.trace.core.scopemanager.ContinuableScope.CONTEXT;
Expand Down Expand Up @@ -248,6 +249,13 @@ public void closePrevious(final boolean finishSpan) {
if (finishSpan && span != null) {
span.finishWithEndToEnd();
}
} else if (top != null) {
log.debug(
SEND_TELEMETRY,
"Scope found at top of stack has source {} when we expect {}. Current span at the top of the stack {}.",
top.source(),
ITERATION,
top.span());
}
}

Expand Down