-
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 smoke test
- Loading branch information
Showing
7 changed files
with
105 additions
and
26 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
56 changes: 56 additions & 0 deletions
56
...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,56 @@ | ||
package datadog.smoketest; | ||
|
||
import com.datadog.debugger.probe.SpanDecorationProbe; | ||
import datadog.trace.api.DDTags; | ||
import datadog.trace.test.agent.decoder.DecodedSpan; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
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); | ||
} | ||
} |