Java Code Examples for brave.propagation.Propagation#injector()
The following examples show how to use
brave.propagation.Propagation#injector() .
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: JmsTracing.java From brave with Apache License 2.0 | 6 votes |
JmsTracing(Builder builder) { // intentionally hidden constructor this.tracing = builder.messagingTracing.tracing(); this.tracer = tracing.tracer(); Propagation<String> propagation = tracing.propagation(); if (JmsTypes.HAS_JMS_PRODUCER) { this.jmsProducerExtractor = propagation.extractor(JMSProducerRequest.GETTER); this.jmsProducerInjector = propagation.injector(JMSProducerRequest.SETTER); } else { this.jmsProducerExtractor = null; this.jmsProducerInjector = null; } this.messageProducerExtractor = propagation.extractor(MessageProducerRequest.GETTER); this.messageProducerInjector = propagation.injector(MessageProducerRequest.SETTER); this.messageConsumerExtractor = propagation.extractor(MessageConsumerRequest.GETTER); this.messageConsumerInjector = propagation.injector(MessageConsumerRequest.SETTER); this.processorExtractor = tracing.propagation().extractor(GETTER); this.producerSampler = builder.messagingTracing.producerSampler(); this.consumerSampler = builder.messagingTracing.consumerSampler(); this.remoteServiceName = builder.remoteServiceName; this.traceIdProperties = new LinkedHashSet<>(tracing.propagation().keys()); }
Example 2
Source File: KafkaTracing.java From brave with Apache License 2.0 | 6 votes |
KafkaTracing(Builder builder) { // intentionally hidden constructor this.messagingTracing = builder.messagingTracing; this.tracer = builder.messagingTracing.tracing().tracer(); Propagation<String> propagation = messagingTracing.tracing().propagation(); this.producerExtractor = propagation.extractor(KafkaProducerRequest.GETTER); this.consumerExtractor = propagation.extractor(KafkaConsumerRequest.GETTER); this.processorExtractor = propagation.extractor(GETTER); this.producerInjector = propagation.injector(KafkaProducerRequest.SETTER); this.consumerInjector = propagation.injector(KafkaConsumerRequest.SETTER); this.producerSampler = messagingTracing.producerSampler(); this.consumerSampler = messagingTracing.consumerSampler(); this.remoteServiceName = builder.remoteServiceName; this.singleRootSpanOnReceiveBatch = builder.singleRootSpanOnReceiveBatch; // We clear the trace ID headers, so that a stale consumer span is not preferred over current // listener. We intentionally don't clear BaggagePropagation.allKeyNames as doing so will // application fields "user_id" or "country_code" this.traceIdHeaders = new LinkedHashSet<>(propagation.keys()); // When baggage or similar is in use, the result != TraceContextOrSamplingFlags.EMPTY this.emptyExtraction = propagation.extractor((c, k) -> null).extract(Boolean.TRUE); }
Example 3
Source File: PropagationTest.java From brave with Apache License 2.0 | 5 votes |
@Override public void accept(Propagation<?> propagation) { TraceContext.Injector<Map<Object, String>> injector = propagation.injector(Map::put); TraceContext.Extractor<Map<Object, String>> extractor = propagation.extractor(Map::get); TraceContext ctx = TraceContext.newBuilder().traceId(1L).spanId(2L).sampled(false).build(); Map<Object, String> map = new LinkedHashMap<>(); injector.inject(ctx, map); assertThat(extractor.extract(map).context()) .isEqualToIgnoringGivenFields(ctx, "traceIdString", "spanIdString"); }
Example 4
Source File: KafkaStreamsTracing.java From brave with Apache License 2.0 | 5 votes |
KafkaStreamsTracing(Builder builder) { // intentionally hidden constructor this.kafkaTracing = builder.kafkaTracing.toBuilder() .singleRootSpanOnReceiveBatch(builder.singleRootSpanOnReceiveBatch) .build(); this.tracer = kafkaTracing.messagingTracing().tracing().tracer(); Propagation<String> propagation = kafkaTracing.messagingTracing().tracing().propagation(); this.extractor = propagation.extractor(KafkaStreamsPropagation.GETTER); this.injector = propagation.injector(KafkaStreamsPropagation.SETTER); this.propagationKeys = new LinkedHashSet<>(propagation.keys()); // When Baggage or similar are in use, the result != TraceContextOrSamplingFlags.EMPTY this.emptyExtraction = propagation.extractor((c, k) -> null).extract(Boolean.TRUE); }