Skip to content

Commit c42402d

Browse files
dougqhclaude
andcommitted
Add KnownTags globalSerial reserve partition for virtual/special tags
Establishes the boundary FIRST_STORED_SERIAL=256: globalSerials [1,256) are reserved for "virtual" tags that are specially handled (redirected to span fields or processed by the tag interceptor) and NOT stored in the TagMap — hand-assigned in tracer core; [256,..) are generated convention tags that ARE stored (slotted/bucketed); 0 stays unknown/string-only. Adds isReserved()/ isStored() so setTag(long) can classify a tag by an O(1) range check (its "needsIntercept by id") before routing to the interceptor vs the slot/bucket store. Both core and the code generator agree on this boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9f8b226 commit c42402d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

internal-api/src/main/java/datadog/trace/api/KnownTags.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ public static int nameHash(long tagId) {
3939
return (int) tagId;
4040
}
4141

42+
/**
43+
* globalSerial partition. {@code [1, FIRST_STORED_SERIAL)} is reserved for "virtual" tags that
44+
* are specially handled (redirected to span fields or processed by the tag interceptor) and are
45+
* NOT stored in the TagMap — these are hand-assigned in tracer core. {@code [FIRST_STORED_SERIAL,
46+
* ..]} is for generated convention tags that ARE stored (slotted/bucketed). {@code globalSerial
47+
* == 0} means unknown / string-only. Both core and the code generator must agree on this
48+
* boundary.
49+
*/
50+
public static final int FIRST_STORED_SERIAL = 256;
51+
52+
/** True if the tagId names a reserved "virtual"/specially-handled tag (not stored in the map). */
53+
public static boolean isReserved(long tagId) {
54+
int globalSerial = globalSerial(tagId);
55+
return globalSerial > 0 && globalSerial < FIRST_STORED_SERIAL;
56+
}
57+
58+
/** True if the tagId names a generated, map-stored (slotted/bucketed) tag. */
59+
public static boolean isStored(long tagId) {
60+
return globalSerial(tagId) >= FIRST_STORED_SERIAL;
61+
}
62+
4263
/**
4364
* Builds a tagId from its parts: {@code globalSerial} (globally unique per known tag), {@code
4465
* fieldPos} (the tag's slot within its span type's positional table), and the tag {@code name}

0 commit comments

Comments
 (0)