-
Notifications
You must be signed in to change notification settings - Fork 304
Fix CodeOrigin for @Trace
annotation
#8344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not calling probe.commit() here. but if insturment is false... we should call commit every time, right?
maybe change the else if below. and just have
if (!instrument) { probe.commit() }
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createProbe
is callingprobe.commit()