Skip to content

Commit bcf743a

Browse files
authored
Merge branch 'master' into dougqh/basedecorator-entry-reuse
2 parents c79acd1 + 19de0d9 commit bcf743a

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/HttpServerDecorator.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE, REQUEST
8080
private final boolean traceClientIpResolverEnabled =
8181
Config.get().isTraceClientIpResolverEnabled();
8282

83+
private final String primaryInstrumentationName;
84+
85+
protected HttpServerDecorator() {
86+
String[] instrumentationNames = instrumentationNames();
87+
this.primaryInstrumentationName =
88+
instrumentationNames != null && instrumentationNames.length > 0
89+
? instrumentationNames[0]
90+
: DEFAULT_INSTRUMENTATION_NAME;
91+
}
92+
93+
protected final String primaryInstrumentationName() {
94+
return primaryInstrumentationName;
95+
}
96+
8397
protected abstract AgentPropagation.ContextVisitor<REQUEST_CARRIER> getter();
8498

8599
protected abstract AgentPropagation.ContextVisitor<RESPONSE> responseGetter();
@@ -152,11 +166,7 @@ public Context extract(REQUEST_CARRIER carrier) {
152166
* @return A new context bundling the span, child of the given parent context.
153167
*/
154168
public Context startSpan(REQUEST_CARRIER carrier, Context parentContext) {
155-
String[] instrumentationNames = instrumentationNames();
156-
String instrumentationName =
157-
instrumentationNames != null && instrumentationNames.length > 0
158-
? instrumentationNames[0]
159-
: DEFAULT_INSTRUMENTATION_NAME;
169+
String instrumentationName = primaryInstrumentationName();
160170
AgentSpanContext extracted = getExtractedSpanContext(parentContext);
161171
// Call IG callbacks
162172
extracted = callIGCallbackStart(extracted);

dd-smoke-tests/src/main/groovy/datadog/smoketest/AbstractSmokeTest.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ abstract class AbstractSmokeTest extends ProcessManager {
287287
}
288288
}
289289

290-
def setupSpec() {
290+
@Override
291+
protected void setupTracesConsumer() {
291292
startServer()
292293
}
293294

dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ abstract class ProcessManager extends Specification {
7171
assert Files.isDirectory(Paths.get(buildDirectory))
7272
assert Files.isRegularFile(Paths.get(shadowJarPath))
7373

74+
setupTracesConsumer()
7475
beforeProcessBuilders()
7576

7677
(0..<numberOfProcesses).each { idx ->
@@ -237,6 +238,8 @@ abstract class ProcessManager extends Specification {
237238
outputThreads.processTestLogLines { return checker(it) }
238239
}
239240

241+
protected abstract void setupTracesConsumer()
242+
240243
protected void beforeProcessBuilders() {}
241244

242245
protected ProcessBuilder createProcessBuilder() {

0 commit comments

Comments
 (0)