Skip to content

Commit 78e523d

Browse files
authored
Rename the code origin tags (#7724)
1 parent 6306f63 commit 78e523d

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/CodeOriginProbe.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.datadog.debugger.probe;
22

33
import static com.datadog.debugger.codeorigin.DebuggerConfiguration.isDebuggerEnabled;
4-
import static datadog.trace.api.DDTags.DD_STACK_CODE_ORIGIN_FRAME;
5-
import static datadog.trace.api.DDTags.DD_STACK_CODE_ORIGIN_TYPE;
4+
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_FRAME;
5+
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_TYPE;
66
import static java.lang.String.format;
77
import static java.util.Arrays.asList;
88
import static java.util.Collections.singletonList;
@@ -98,19 +98,19 @@ private void recordStackFrames(
9898
entrySpanProbe ? asList(span, span.getLocalRootSpan()) : singletonList(span);
9999

100100
for (AgentSpan s : agentSpans) {
101-
s.setTag(DD_STACK_CODE_ORIGIN_TYPE, entrySpanProbe ? "entry" : "exit");
101+
s.setTag(DD_CODE_ORIGIN_TYPE, entrySpanProbe ? "entry" : "exit");
102102

103103
for (int i = 0; i < entries.size(); i++) {
104104
StackTraceElement info = entries.get(i);
105-
s.setTag(format(DD_STACK_CODE_ORIGIN_FRAME, i, "file"), info.getFileName());
106-
s.setTag(format(DD_STACK_CODE_ORIGIN_FRAME, i, "method"), info.getMethodName());
107-
s.setTag(format(DD_STACK_CODE_ORIGIN_FRAME, i, "line"), info.getLineNumber());
108-
s.setTag(format(DD_STACK_CODE_ORIGIN_FRAME, i, "type"), info.getClassName());
105+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "file"), info.getFileName());
106+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "method"), info.getMethodName());
107+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "line"), info.getLineNumber());
108+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "type"), info.getClassName());
109109
if (i == 0 && signature != null) {
110-
s.setTag(format(DD_STACK_CODE_ORIGIN_FRAME, i, "signature"), signature);
110+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "signature"), signature);
111111
}
112112
if (i == 0 && snapshotId != null) {
113-
s.setTag(format(DD_STACK_CODE_ORIGIN_FRAME, i, "snapshot_id"), snapshotId);
113+
s.setTag(format(DD_CODE_ORIGIN_FRAME, i, "snapshot_id"), snapshotId);
114114
}
115115
}
116116
}

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/origin/CodeOriginTest.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import static com.datadog.debugger.agent.ConfigurationAcceptor.Source.REMOTE_CONFIG;
44
import static com.datadog.debugger.util.TestHelper.setFieldInConfig;
5-
import static datadog.trace.api.DDTags.DD_STACK_CODE_ORIGIN_FRAME;
6-
import static datadog.trace.api.DDTags.DD_STACK_CODE_ORIGIN_TYPE;
5+
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_FRAME;
6+
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_PREFIX;
7+
import static datadog.trace.api.DDTags.DD_CODE_ORIGIN_TYPE;
78
import static java.lang.String.format;
89
import static java.util.Arrays.asList;
910
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -191,16 +192,16 @@ private void waitForInstrumentation() {
191192
private static void checkEntrySpanTags(MutableSpan span, boolean includeSnapshot) {
192193
String keys = format("Existing keys for %s: %s", span.getOperationName(), ldKeys(span));
193194

194-
assertEquals(span.getTag(DD_STACK_CODE_ORIGIN_TYPE), "entry", keys);
195-
assertKeyPresent(span, DD_STACK_CODE_ORIGIN_TYPE);
196-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "file"));
197-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "line"));
198-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "method"));
199-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "signature"));
200-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "type"));
195+
assertEquals(span.getTag(DD_CODE_ORIGIN_TYPE), "entry", keys);
196+
assertKeyPresent(span, DD_CODE_ORIGIN_TYPE);
197+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "file"));
198+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "line"));
199+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "method"));
200+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "signature"));
201+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "type"));
201202

202203
if (includeSnapshot) {
203-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "snapshot_id"));
204+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "snapshot_id"));
204205
}
205206
}
206207

@@ -224,26 +225,26 @@ private static void checkExitSpanTags(MutableSpan span, boolean includeSnapshot)
224225
String keys =
225226
format("Existing keys for %s: %s", span.getOperationName(), new TreeSet<>(ldKeys(span)));
226227

227-
assertKeyPresent(span, DD_STACK_CODE_ORIGIN_TYPE);
228-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "file"));
229-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "line"));
230-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "method"));
231-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "type"));
228+
assertKeyPresent(span, DD_CODE_ORIGIN_TYPE);
229+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "file"));
230+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "line"));
231+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "method"));
232+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "type"));
232233
if (includeSnapshot) {
233-
assertKeyPresent(span, format(DD_STACK_CODE_ORIGIN_FRAME, 0, "snapshot_id"));
234+
assertKeyPresent(span, format(DD_CODE_ORIGIN_FRAME, 0, "snapshot_id"));
234235
}
235236

236237
MutableSpan rootSpan = span.getLocalRootSpan();
237-
assertEquals(rootSpan.getTag(DD_STACK_CODE_ORIGIN_TYPE), "entry", keys);
238-
assertNotNull(rootSpan.getTag(format(DD_STACK_CODE_ORIGIN_FRAME, 1, "file")));
239-
assertNotNull(rootSpan.getTag(format(DD_STACK_CODE_ORIGIN_FRAME, 1, "line")));
240-
assertNotNull(rootSpan.getTag(format(DD_STACK_CODE_ORIGIN_FRAME, 1, "method")));
241-
assertNotNull(rootSpan.getTag(format(DD_STACK_CODE_ORIGIN_FRAME, 1, "type")));
238+
assertEquals(rootSpan.getTag(DD_CODE_ORIGIN_TYPE), "entry", keys);
239+
assertNotNull(rootSpan.getTag(format(DD_CODE_ORIGIN_FRAME, 1, "file")));
240+
assertNotNull(rootSpan.getTag(format(DD_CODE_ORIGIN_FRAME, 1, "line")));
241+
assertNotNull(rootSpan.getTag(format(DD_CODE_ORIGIN_FRAME, 1, "method")));
242+
assertNotNull(rootSpan.getTag(format(DD_CODE_ORIGIN_FRAME, 1, "type")));
242243
}
243244

244245
private static Set<String> ldKeys(MutableSpan span) {
245246
return span.getTags().keySet().stream()
246-
.filter(key -> key.startsWith("_dd.ld") || key.startsWith("_dd.stack"))
247+
.filter(key -> key.startsWith(DD_CODE_ORIGIN_PREFIX))
247248
.collect(Collectors.toCollection(TreeSet::new));
248249
}
249250

dd-trace-api/src/main/java/datadog/trace/api/DDTags.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
public class DDTags {
44

5-
private static final String DD_LD_PREFIX = "_dd.ld.";
6-
public static final String DD_STACK_CODE_ORIGIN_PREFIX = DD_LD_PREFIX + "code_origin.";
5+
public static final String DD_CODE_ORIGIN_PREFIX = "_dd.code_origin.";
76

8-
public static final String DD_STACK_CODE_ORIGIN_TYPE = DD_STACK_CODE_ORIGIN_PREFIX + "type";
9-
// _dd.ld.code_origin.frames.%d.file|line|method|type|snapshot_id
10-
public static final String DD_STACK_CODE_ORIGIN_FRAME =
11-
DD_STACK_CODE_ORIGIN_PREFIX + "frames.%d.%s";
7+
public static final String DD_CODE_ORIGIN_TYPE = DD_CODE_ORIGIN_PREFIX + "type";
8+
// _dd.code_origin.frames.%d.file|line|method|type|snapshot_id
9+
public static final String DD_CODE_ORIGIN_FRAME = DD_CODE_ORIGIN_PREFIX + "frames.%d.%s";
1210

1311
public static final String SPAN_TYPE = "span.type";
1412
public static final String SERVICE_NAME = "service.name";

0 commit comments

Comments
 (0)