Skip to content

Commit 512a3ae

Browse files
committed
logging
1 parent 24f8e54 commit 512a3ae

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

dd-java-agent/instrumentation/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/TomcatServerInstrumentation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public static ContextScope onService(@Advice.Argument(0) org.apache.coyote.Reque
131131

132132
final AgentSpan span = DECORATE.startSpanFromContext("http-server", req, extractedContext);
133133
final ContextScope scope = extractedContext.with(span).attach();
134+
// final ContextScope scope = activateSpan(span);
134135
// This span is finished when Request.recycle() is called by RequestInstrumentation.
135136
DECORATE.afterStart(span);
136137

dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
10411041
if (isDataStreamsEnabled()) {
10421042
TEST_DATA_STREAMS_WRITER.waitForGroups(1)
10431043
}
1044-
1044+
println(request)
1045+
println(response)
10451046
expect:
10461047
if (bubblesResponse()) {
10471048
assert response.code() == REDIRECT.status

dd-trace-core/src/main/java/datadog/trace/core/scopemanager/ContinuableScopeManager.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import java.util.concurrent.ConcurrentMap;
3737
import java.util.concurrent.CopyOnWriteArrayList;
3838
import java.util.concurrent.TimeUnit;
39+
40+
import de.thetaphi.forbiddenapis.SuppressForbidden;
3941
import org.slf4j.Logger;
4042
import org.slf4j.LoggerFactory;
4143

@@ -122,6 +124,7 @@ private AgentScope.Continuation captureSpan(Context context, byte source, AgentS
122124
return new ScopeContinuation(this, context, source, traceCollector).register();
123125
}
124126

127+
@SuppressForbidden
125128
private AgentScope activate(
126129
final AgentSpan span,
127130
final byte source,
@@ -155,12 +158,20 @@ private AgentScope activate(
155158

156159
final ContinuableScope scope =
157160
new ContinuableScope(this, context, source, asyncPropagation, createScopeState(context));
161+
System.out.println("Scope size prior: " + scopeStack.depth());
158162
scopeStack.push(scope);
163+
System.out.println("Scope size prior: " + scopeStack.depth());
159164
healthMetrics.onActivateScope();
160165

166+
if (iterationKeepAlive > 0 && currentDepth == 0) {
167+
// For context-based scopes, only add them if they're going to be long-lived
168+
scheduleRootIterationScopeCleanup(scopeStack, scope);
169+
}
170+
161171
return scope;
162172
}
163173

174+
@SuppressForbidden
164175
private AgentScope activate(final Context context) {
165176
ScopeStack scopeStack = scopeStack();
166177

@@ -185,9 +196,17 @@ private AgentScope activate(final Context context) {
185196

186197
final ContinuableScope scope =
187198
new ContinuableScope(this, context, CONTEXT, asyncPropagation, createScopeState(context));
199+
System.out.println("Context: " + context);
200+
System.out.println("Scope size prior: " + scopeStack.depth());
188201
scopeStack.push(scope);
202+
System.out.println("Scope size prior: " + scopeStack.depth());
189203
healthMetrics.onActivateScope();
190204

205+
if (iterationKeepAlive > 0 && currentDepth == 0) {
206+
// For context-based scopes, only add them if they're going to be long-lived
207+
scheduleRootIterationScopeCleanup(scopeStack, scope);
208+
}
209+
191210
return scope;
192211
}
193212

@@ -304,8 +323,13 @@ public void rollbackActiveToCheckpoint() {
304323
}
305324
}
306325

326+
@SuppressForbidden
307327
public AgentSpan activeSpan() {
308328
final ContinuableScope active = scopeStack().active();
329+
330+
System.out.println("Scope size prior: " + scopeStack().depth());
331+
System.out.println("scopeStack(): " + scopeStack());
332+
System.out.println("active: " + active);
309333
return active == null ? null : active.span();
310334
}
311335

0 commit comments

Comments
 (0)