@Test public void testExtractSpanContext() { HttpHeaders testHttpHeaders = new HttpHeaders(); testHttpHeaders.add("test-header-key", "test-header-value"); final HashMap<String, String> mapHeaders = new HashMap<>(); testHttpHeaders.forEach((key, value) -> { mapHeaders.put(key, value.get(0)); }); when(tracer.extract(eq(Format.Builtin.HTTP_HEADERS), ArgumentMatchers.any(TextMapAdapter.class))).thenReturn(testSpanContext); io.opentracing.SpanContext resultSpanContext = utilUnderTest.extractParentSpan(testHttpHeaders); Assert.assertEquals(resultSpanContext.toTraceId(), traceId.toString()); Assert.assertEquals(resultSpanContext.toSpanId(), spanId.toString()); }
public SpanContext extractParentSpan(HttpHeaders headers){ final HashMap<String, String> mapHeaders = new HashMap<>(); headers.forEach((key, value) -> { mapHeaders.put(key, value.get(0)); }); try { SpanContext parentSpan = modelServiceApiTracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(mapHeaders)); return parentSpan; } catch (IllegalArgumentException e) { log.error("Exception during extracting parentSpan", e); } return null; }
Trace { public SpanContext extractParentSpan(HttpHeaders headers){ final HashMap<String, String> mapHeaders = new HashMap<>(); headers.forEach((key, value) -> { mapHeaders.put(key, value.get(0)); }); try { SpanContext parentSpan = modelServiceApiTracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(mapHeaders)); return parentSpan; } catch (IllegalArgumentException e) { log.error("Exception during extracting parentSpan", e); } return null; } }
Trace { public SpanContext extractParentSpan(HttpHeaders headers){ final HashMap<String, String> mapHeaders = new HashMap<>(); headers.forEach((key, value) -> { mapHeaders.put(key, value.get(0)); }); try { SpanContext parentSpan = modelServiceApiTracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(mapHeaders)); return parentSpan; } catch (IllegalArgumentException e) { log.error("Exception during extracting parentSpan", e); } return null; } @Autowired  Trace(Tracer tracer); }
Trace { public SpanContext extractParentSpan(HttpHeaders headers){ final HashMap<String, String> mapHeaders = new HashMap<>(); headers.forEach((key, value) -> { mapHeaders.put(key, value.get(0)); }); try { SpanContext parentSpan = modelServiceApiTracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(mapHeaders)); return parentSpan; } catch (IllegalArgumentException e) { log.error("Exception during extracting parentSpan", e); } return null; } @Autowired  Trace(Tracer tracer); Span startSpan(String operationName, SpanContext spnContext); SpanContext extractParentSpan(HttpHeaders headers); }
Trace { public SpanContext extractParentSpan(HttpHeaders headers){ final HashMap<String, String> mapHeaders = new HashMap<>(); headers.forEach((key, value) -> { mapHeaders.put(key, value.get(0)); }); try { SpanContext parentSpan = modelServiceApiTracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(mapHeaders)); return parentSpan; } catch (IllegalArgumentException e) { log.error("Exception during extracting parentSpan", e); } return null; } @Autowired  Trace(Tracer tracer); Span startSpan(String operationName, SpanContext spnContext); SpanContext extractParentSpan(HttpHeaders headers);  }