-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CodeOrigin for @trace annotation
add a param for captureCodeOrigin method to indicate if we need to instrument for the CodeOriginProbe. the instrumentation for the @trace annotation insert a call to start and activate the span. so we just need to call captureCodeOrigin after the activation so we benefit from tracer instrumentation without generating a call to CodeOriginProbe. That way are in sync with the tracer instrumentation. add smoke test
- Loading branch information
Showing
9 changed files
with
111 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...debugger-integration-tests/src/test/java/datadog/smoketest/CodeOriginIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package datadog.smoketest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import datadog.trace.api.DDTags; | ||
import datadog.trace.test.agent.decoder.DecodedSpan; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class CodeOriginIntegrationTest extends ServerAppDebuggerIntegrationTest { | ||
|
||
private static final String DD_CODE_ORIGIN_FRAMES_0_FILE = | ||
String.format(DDTags.DD_CODE_ORIGIN_FRAME, 0, "file"); | ||
private static final String DD_CODE_ORIGIN_FRAMES_0_METHOD = | ||
String.format(DDTags.DD_CODE_ORIGIN_FRAME, 0, "method"); | ||
private static final String DD_CODE_ORIGIN_FRAMES_0_SIGNATURE = | ||
String.format(DDTags.DD_CODE_ORIGIN_FRAME, 0, "signature"); | ||
private static final String DD_CODE_ORIGIN_FRAMES_0_LINE = | ||
String.format(DDTags.DD_CODE_ORIGIN_FRAME, 0, "line"); | ||
|
||
@Override | ||
protected ProcessBuilder createProcessBuilder(Path logFilePath, String... params) { | ||
List<String> commandParams = getDebuggerCommandParams(); | ||
commandParams.add("-Ddd.trace.enabled=true"); // explicitly enable tracer | ||
commandParams.add("-Ddd.code.origin.for.spans.enabled=true"); | ||
return ProcessBuilderHelper.createProcessBuilder( | ||
commandParams, logFilePath, getAppClass(), params); | ||
} | ||
|
||
@Test | ||
@DisplayName("testCodeOriginTraceAnnotation") | ||
void testCodeOriginTraceAnnotation() throws Exception { | ||
execute(appUrl, TRACED_METHOD_NAME); | ||
waitForInstrumentation(appUrl); | ||
execute(appUrl, TRACED_METHOD_NAME); | ||
AtomicBoolean codeOrigin = new AtomicBoolean(); | ||
registerTraceListener( | ||
decodedTrace -> { | ||
for (DecodedSpan span : decodedTrace.getSpans()) { | ||
if (isTracedFullMethodSpan(span)) { | ||
if (span.getMeta().containsKey(DDTags.DD_CODE_ORIGIN_TYPE)) { | ||
assertEquals("entry", span.getMeta().get(DDTags.DD_CODE_ORIGIN_TYPE)); | ||
assertEquals( | ||
"ServerDebuggerTestApplication.java", | ||
span.getMeta().get(DD_CODE_ORIGIN_FRAMES_0_FILE)); | ||
assertEquals("runTracedMethod", span.getMeta().get(DD_CODE_ORIGIN_FRAMES_0_METHOD)); | ||
assertEquals( | ||
"(java.lang.String)", span.getMeta().get(DD_CODE_ORIGIN_FRAMES_0_SIGNATURE)); | ||
assertEquals("133", span.getMeta().get(DD_CODE_ORIGIN_FRAMES_0_LINE)); | ||
codeOrigin.set(true); | ||
} | ||
} | ||
} | ||
}); | ||
processRequests(codeOrigin::get); | ||
} | ||
} |