Skip to content

Commit f2cd089

Browse files
committed
Add meaningful constant UNSET to ProductTraceSource 0
1 parent 7c79879 commit f2cd089

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

dd-trace-core/src/main/java/datadog/trace/core/propagation/ptags/PTagsCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static String headerValue(PTagsCodec codec, PTags ptags) {
3838
if (ptags.getTraceIdHighOrderBitsHexTagValue() != null) {
3939
size = codec.appendTag(sb, TRACE_ID_TAG, ptags.getTraceIdHighOrderBitsHexTagValue(), size);
4040
}
41-
if (ptags.getPropagatedTraceSource() != 0) {
41+
if (ptags.getPropagatedTraceSource() != ProductTraceSource.UNSET) {
4242
size =
4343
codec.appendTag(
4444
sb,
@@ -92,7 +92,7 @@ static void fillTagMap(PTags propagationTags, Map<String, String> tagMap) {
9292
DECISION_MAKER_TAG.forType(Encoding.DATADOG).toString(),
9393
propagationTags.getDecisionMakerTagValue().forType(Encoding.DATADOG).toString());
9494
}
95-
if (propagationTags.getPropagatedTraceSource() != 0) {
95+
if (propagationTags.getPropagatedTraceSource() != ProductTraceSource.UNSET) {
9696
tagMap.put(
9797
TRACE_SOURCE_TAG.forType(Encoding.DATADOG).toString(),
9898
TagValue.from(

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

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

33
public class ProductTraceSource {
44

5+
public static final int UNSET = 0;
6+
57
public static final int APM = 0x01;
68
public static final int ASM = 0x02;
79
public static final int DSM = 0x04;

internal-api/src/test/groovy/datadog/trace/api/ProductTraceSourceTest.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ProductTraceSourceTest extends DDSpecification {
1313

1414
where:
1515
init | newProduct | expected
16-
0 | ProductTraceSource.ASM | ProductTraceSource.ASM
16+
ProductTraceSource.UNSET | ProductTraceSource.ASM | ProductTraceSource.ASM
1717
ProductTraceSource.ASM | ProductTraceSource.DSM | 6
1818
}
1919

@@ -39,7 +39,7 @@ class ProductTraceSourceTest extends DDSpecification {
3939

4040
where:
4141
value | expected
42-
0 | "00"
42+
ProductTraceSource.UNSET | "00"
4343
ProductTraceSource.ASM | "02"
4444
}
4545

@@ -52,9 +52,9 @@ class ProductTraceSourceTest extends DDSpecification {
5252

5353
where:
5454
hex | expected
55-
"00" | 0
56-
null | 0
57-
"" | 0
55+
"00" | ProductTraceSource.UNSET
56+
null | ProductTraceSource.UNSET
57+
"" | ProductTraceSource.UNSET
5858
"02" | ProductTraceSource.ASM
5959
}
6060
}

0 commit comments

Comments
 (0)