Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 2705598

Browse files
authored
Default w3c sampled flag to 01 so the OTEL collector does not ignore the spans (#105)
Receiving OTEL instrumentation ignores spans coming with the 00 sampled flag. This is a stop-gap measure to ensure w3c parser hooks work with an OTEL receiver. Ideally, we would like to set the sampled flag based on an actual sampler, but that requires further investigation.
1 parent 1c04f83 commit 2705598

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

beeline-core/src/main/java/io/honeycomb/beeline/tracing/propagation/W3CPropagationCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public Optional<Map<String, String>> encode(PropagationContext context) {
173173
return Optional.empty();
174174
}
175175

176-
final String traceParent = String.join(SEGMENT_SEPARATOR, DEFAULT_VERSION, context.getTraceId(), context.getSpanId(), NOT_SAMPLED_TRACEFLAGS);
176+
final String traceParent = String.join(SEGMENT_SEPARATOR, DEFAULT_VERSION, context.getTraceId(), context.getSpanId(), SAMPLED_TRACEFLAGS);
177177

178178
// If no dataset or tracefields, just return trace parent header
179179
if (context.getDataset() == null && context.getTraceFields().isEmpty()) {

beeline-core/src/test/java/io/honeycomb/beeline/tracing/propagation/W3CPropagationCodecTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public void GIVEN_aPopulatedContext_EXPECT_aValidHeaderValue() {
243243
final Map<String, String> encoded = codec.encode(new PropagationContext(traceId, spanId, null, null)).get();
244244

245245
assertThat(encoded).isEqualTo(
246-
Collections.singletonMap(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "00"))
246+
Collections.singletonMap(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "01"))
247247
);
248248
}
249249

@@ -254,11 +254,11 @@ public void GIVEN_aPopulatedContextWithDataset_EXPECT_aValidHeaderValueWithTrace
254254
String dataset = "test-dataset";
255255

256256
final Map<String, String> headers = new HashMap<>();
257-
headers.put(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "00"));
257+
headers.put(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "01"));
258258
headers.put(W3CPropagationCodec.W3C_TRACESTATE_HEADER, "hny=ZGF0YXNldD10ZXN0LWRhdGFzZXQ=");
259259

260260
final Map<String, String> encoded = codec.encode(new PropagationContext(traceId, spanId, dataset, null)).get();
261-
assertThat(headers).isEqualTo(encoded);
261+
assertThat(encoded).isEqualTo(headers);
262262
}
263263

264264
@Test
@@ -270,11 +270,11 @@ public void GIVEN_aPopulatedContextWithFields_EXPECT_aValidHeaderValueWithTraceS
270270
fields.put("one", "two");
271271

272272
final Map<String, String> headers = new HashMap<>();
273-
headers.put(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "00"));
273+
headers.put(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "01"));
274274
headers.put(W3CPropagationCodec.W3C_TRACESTATE_HEADER, "hny=Zm9vPWJhcixvbmU9dHdv");
275275

276276
final Map<String, String> encoded = codec.encode(new PropagationContext(traceId, spanId, null, fields)).get();
277-
assertThat(headers).isEqualTo(encoded);
277+
assertThat(encoded).isEqualTo(headers);
278278
}
279279

280280
@Test
@@ -287,10 +287,10 @@ public void GIVEN_aPopulatedContextWithDatasetAndFields_EXPECT_aValidHeaderValue
287287
fields.put("one", "two");
288288

289289
final Map<String, String> headers = new HashMap<>();
290-
headers.put(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "00"));
290+
headers.put(W3CPropagationCodec.W3C_TRACEPARENT_HEADER, String.join("-", "00", traceId, spanId, "01"));
291291
headers.put(W3CPropagationCodec.W3C_TRACESTATE_HEADER, "hny=ZGF0YXNldD10ZXN0LWRhdGFzZXQsZm9vPWJhcixvbmU9dHdv");
292292

293293
final Map<String, String> encoded = codec.encode(new PropagationContext(traceId, spanId, dataset, fields)).get();
294-
assertThat(headers).isEqualTo(encoded);
294+
assertThat(encoded).isEqualTo(headers);
295295
}
296296
}

0 commit comments

Comments
 (0)