Skip to content

Commit

Permalink
adding warning to XRay extractor when traceId/spanId missing (#4420)
Browse files Browse the repository at this point in the history
* adding warning to XRay extractor when traceId/spanId missing

* switched to FINEST
  • Loading branch information
kuba-wu committed May 5, 2022
1 parent 3f2317f commit 57c858f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -228,6 +228,10 @@ private static <C> Context getContextFromHeader(
return context;
}

if (spanId == null || traceId == null) {
logger.finest("Both traceId and spanId are required to extract a valid span context. ");
}

SpanContext spanContext =
SpanContext.createFromRemoteParent(
StringUtils.padLeft(traceId, TraceId.getLength()),
Expand Down
Expand Up @@ -346,6 +346,14 @@ void extract_InvalidFlags_NonNumeric() {
verifyInvalidBehavior(invalidHeaders);
}

@Test
void extract_Invalid_NoSpanId() {
Map<String, String> invalidHeaders = new LinkedHashMap<>(1);
invalidHeaders.put(TRACE_HEADER_KEY, "Root=1-622422bf-59625fe25708d4660735d8ef");

verifyInvalidBehavior(invalidHeaders);
}

private void verifyInvalidBehavior(Map<String, String> invalidHeaders) {
Context input = Context.current();
Context result = xrayPropagator.extract(input, invalidHeaders, getter);
Expand Down

0 comments on commit 57c858f

Please sign in to comment.