Java Code Examples for brave.propagation.TraceContext.Extractor#extract()
The following examples show how to use
brave.propagation.TraceContext.Extractor#extract() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BraveTracer.java From brave-opentracing with Apache License 2.0 | 5 votes |
/** * Extracts the underlying context using B3 encoding by default. Null is returned when there is no * encoded context in the carrier, or upon error extracting it. */ @Nullable @Override public <C> BraveSpanContext extract(Format<C> format, C carrier) { TraceContextOrSamplingFlags extractionResult; if (carrier instanceof BinaryExtract) { extractionResult = BinaryCodec.INSTANCE.extract((BinaryExtract) carrier); } else { Extractor<C> extractor = (Extractor<C>) formatToExtractor.get(format); if (extractor == null) { throw new UnsupportedOperationException(format + " not in " + formatToExtractor.keySet()); } extractionResult = extractor.extract(carrier); } if (emptyExtractions.contains(extractionResult)) return null; return BraveSpanContext.create(extractionResult); }
Example 2
Source File: JmsTracing.java From brave with Apache License 2.0 | 5 votes |
<R> TraceContextOrSamplingFlags extractAndClearTraceIdProperties( Extractor<R> extractor, R request, Message message ) { TraceContextOrSamplingFlags extracted = extractor.extract(request); // Clear propagation regardless of extraction as JMS requires clearing as a means to make the // message writable PropertyFilter.filterProperties(message, traceIdProperties); return extracted; }
Example 3
Source File: KafkaTracing.java From brave with Apache License 2.0 | 5 votes |
<R> TraceContextOrSamplingFlags extractAndClearTraceIdHeaders( Extractor<R> extractor, R request, Headers headers ) { TraceContextOrSamplingFlags extracted = extractor.extract(request); // Clear any propagation keys present in the headers if (extracted.samplingFlags() == null) { // then trace IDs were extracted clearTraceIdHeaders(headers); } return extracted; }
Example 4
Source File: SpringRabbitTracing.java From brave with Apache License 2.0 | 5 votes |
<R> TraceContextOrSamplingFlags extractAndClearTraceIdHeaders( Extractor<R> extractor, R request, Message message ) { TraceContextOrSamplingFlags extracted = extractor.extract(request); // Clear any propagation keys present in the headers if (extracted.samplingFlags() == null) { // then trace IDs were extracted MessageProperties properties = message.getMessageProperties(); if (properties != null) clearTraceIdHeaders(properties.getHeaders()); } return extracted; }