brave.baggage.BaggagePropagation Java Examples
The following examples show how to use
brave.baggage.BaggagePropagation.
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: ITRemote.java From brave with Apache License 2.0 | 6 votes |
protected ITRemote() { CurrentTraceContext.Builder currentTraceContextBuilder = currentTraceContextBuilder(); if (currentTraceContextBuilder instanceof StrictCurrentTraceContext.Builder) { currentTraceContext = currentTraceContextBuilder.build(); checkForLeakedScopes = (Closeable) currentTraceContext; } else { StrictScopeDecorator strictScopeDecorator = StrictScopeDecorator.create(); currentTraceContext = currentTraceContextBuilder .addScopeDecorator(strictScopeDecorator).build(); checkForLeakedScopes = strictScopeDecorator; } propagationFactory = BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.newBuilder(BAGGAGE_FIELD) .addKeyName(BAGGAGE_FIELD_KEY) .build()).build(); tracing = tracingBuilder(Sampler.ALWAYS_SAMPLE).build(); }
Example #2
Source File: ExtraFieldPropagationFactoryBeanTest.java From brave with Apache License 2.0 | 6 votes |
@Test public void fields() { context = new XmlBeans("" + "<bean id=\"propagationFactory\" class=\"brave.spring.beans.ExtraFieldPropagationFactoryBean\">\n" + " <property name=\"fields\">\n" + " <list>\n" + " <value>customer-id</value>\n" + " <value>x-vcap-request-id</value>\n" + " </list>\n" + " </property>" + "</bean>" ); Propagation<String> propagation = context.getBean("propagationFactory", Propagation.Factory.class).get(); assertThat(BaggagePropagation.allKeyNames(propagation)).endsWith( "customer-id", "x-vcap-request-id" ); }
Example #3
Source File: BaggagePropagationFactoryBeanTest.java From brave with Apache License 2.0 | 6 votes |
@Test public void customizers() { context = new XmlBeans("" + "<bean id=\"propagationFactory\" class=\"brave.spring.beans.BaggagePropagationFactoryBean\">\n" + " <property name=\"customizers\">\n" + " <list>\n" + " <util:constant static-field=\"" + getClass().getName() + ".CUSTOMIZER_ONE\"/>\n" + " <util:constant static-field=\"" + getClass().getName() + ".CUSTOMIZER_TWO\"/>\n" + " </list>\n" + " </property>\n" + "</bean>\n" ); context.getBean("propagationFactory", Propagation.Factory.class); verify(CUSTOMIZER_ONE).customize(any(BaggagePropagation.FactoryBuilder.class)); verify(CUSTOMIZER_TWO).customize(any(BaggagePropagation.FactoryBuilder.class)); }
Example #4
Source File: BaggagePropagationFactoryBeanTest.java From brave with Apache License 2.0 | 6 votes |
/** Spring is graceful about a single field being substitutable for a list of size one */ @Test public void configs_no_list() { context = new XmlBeans("" + "<bean id=\"userIdBaggageField\" class=\"brave.baggage.BaggageField\" factory-method=\"create\">\n" + " <constructor-arg value=\"userId\" />\n" + "</bean>\n" + "<bean id=\"propagationFactory\" class=\"brave.spring.beans.BaggagePropagationFactoryBean\">\n" + " <property name=\"configs\">\n" + " <bean class=\"brave.spring.beans.SingleBaggageFieldFactoryBean\">\n" + " <property name=\"field\" ref=\"userIdBaggageField\" />\n" + " <property name=\"keyNames\" value=\"userid\" />\n" + " </bean>\n" + " </property>\n" + "</bean>" ); Propagation<String> propagation = context.getBean("propagationFactory", Propagation.Factory.class).get(); assertThat(BaggagePropagation.allKeyNames(propagation)) .endsWith("userid"); }
Example #5
Source File: EndToEndBenchmarks.java From brave with Apache License 2.0 | 6 votes |
public TracedBaggage() { super(Tracing.newBuilder() .propagationFactory(BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.remote(REQUEST_ID)) .add(SingleBaggageField.newBuilder(COUNTRY_CODE) .addKeyName("baggage-country-code") .build()) .add(SingleBaggageField.newBuilder(USER_ID) .addKeyName("baggage-user-id") .build()) .build()) .addSpanHandler(new SpanHandler() { // intentionally not NOOP to ensure spans report }) .build()); }
Example #6
Source File: AWSPropagationTest.java From zipkin-aws with Apache License 2.0 | 6 votes |
TraceContext contextWithPassThrough() { extractor = BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(BaggagePropagationConfig.SingleBaggageField.remote(AWSPropagation.FIELD_AMZN_TRACE_ID)) .build() .get() .extractor(Map::get); TraceContextOrSamplingFlags extracted = extractor.extract(carrier); // sanity check assertThat(extracted.samplingFlags()).isEqualTo(SamplingFlags.EMPTY); assertThat(extracted.extra()).isNotEmpty(); // Make a context that wasn't from AWSPropagation return TraceContext.newBuilder() .traceId(1L) .spanId(2L) .sampled(true) .addExtra(extracted.extra().get(0)) .build(); }
Example #7
Source File: BraveTracer.java From brave with Apache License 2.0 | 5 votes |
BraveTracer(brave.Tracing tracing) { this.tracing = tracing; tracer = tracing.tracer(); Set<String> lcPropagationKeys = new LinkedHashSet<>(); for (String keyName : BaggagePropagation.allKeyNames(tracing.propagation())) { lcPropagationKeys.add(keyName.toLowerCase(Locale.ROOT)); } injector = tracing.propagation().injector(TextMapPropagation.SETTER); clientInjector = tracing.propagation().injector(TextMapPropagation.REMOTE_SETTER.CLIENT); producerInjector = tracing.propagation().injector(TextMapPropagation.REMOTE_SETTER.PRODUCER); consumerInjector = tracing.propagation().injector(TextMapPropagation.REMOTE_SETTER.CONSUMER); extractor = new TextMapExtractor(tracing.propagation(), lcPropagationKeys, TextMapPropagation.GETTER); }
Example #8
Source File: ServletBenchmarks.java From brave with Apache License 2.0 | 5 votes |
public TracedBaggage() { super(TracingFilter.create(Tracing.newBuilder() .propagationFactory(BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.remote(BAGGAGE_FIELD)).build()) .spanReporter(Reporter.NOOP) .build())); }
Example #9
Source File: JerseyServerBenchmarks.java From brave with Apache License 2.0 | 5 votes |
@Override public Set<Object> getSingletons() { return new LinkedHashSet<>(asList(new Resource(), TracingApplicationEventListener.create( HttpTracing.create(Tracing.newBuilder() .propagationFactory(BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.remote(BAGGAGE_FIELD)).build()) .spanReporter(Reporter.NOOP) .build()) ))); }
Example #10
Source File: BaggagePropagationFactoryBean.java From brave with Apache License 2.0 | 5 votes |
@Override public Propagation.Factory getObject() { BaggagePropagation.FactoryBuilder builder = BaggagePropagation.newFactoryBuilder(propagationFactory); if (configs != null) { builder.clear(); for (BaggagePropagationConfig config : configs) { builder.add(config); } } if (customizers != null) { for (BaggagePropagationCustomizer customizer : customizers) customizer.customize(builder); } return builder.build(); }
Example #11
Source File: BaggagePropagationFactoryBeanTest.java From brave with Apache License 2.0 | 5 votes |
@Test public void configs() { context = new XmlBeans("" + "<bean id=\"userIdBaggageField\" class=\"brave.baggage.BaggageField\" factory-method=\"create\">\n" + " <constructor-arg value=\"userId\" />\n" + "</bean>\n" + "<bean id=\"propagationFactory\" class=\"brave.spring.beans.BaggagePropagationFactoryBean\">\n" + " <property name=\"configs\">\n" + " <list>\n" + " <bean class=\"brave.spring.beans.SingleBaggageFieldFactoryBean\">\n" + " <property name=\"field\" ref=\"userIdBaggageField\"/>\n" + " <property name=\"keyNames\">\n" + " <list>\n" + " <value>baggage_user_id</value>\n" + " <value>baggage-user-id</value>\n" + " </list>\n" + " </property>\n" + " </bean>\n" + " </list>\n" + " </property>\n" + "</bean>" ); Propagation<String> propagation = context.getBean("propagationFactory", Propagation.Factory.class).get(); assertThat(BaggagePropagation.allKeyNames(propagation)).endsWith( "baggage_user_id", "baggage-user-id" ); }
Example #12
Source File: OpenTracing0_33_BraveSpanTest.java From brave-opentracing with Apache License 2.0 | 5 votes |
void init(Tracing.Builder tracingBuilder) { if (brave != null) brave.close(); brave = tracingBuilder .localServiceName("tracer") .currentTraceContext(currentTraceContext) .addSpanHandler(spans) .propagationFactory(BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.remote(BaggageField.create("client-id"))) .build()).build(); tracer = BraveTracer.create(brave); }
Example #13
Source File: TraceAutoConfigurationPropagationCustomizationTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Bean public BaggagePropagation.FactoryBuilder b3Single() { return BaggagePropagation.newFactoryBuilder(B3SinglePropagation.FACTORY); }
Example #14
Source File: TraceAutoConfigurationTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Bean BaggagePropagation.FactoryBuilder baggagePropagationFactoryBuilderBean() { return BaggagePropagation.newFactoryBuilder(B3SinglePropagation.FACTORY); }
Example #15
Source File: TraceCustomFilterResponseInjectorTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Bean BaggagePropagation.FactoryBuilder baggagePropagationFactoryBuilder() { // Use b3 single format as it is less verbose return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder() .injectFormat(CLIENT, SINGLE_NO_PARENT).build()); }
Example #16
Source File: TracingConfiguration.java From brave-webmvc-example with MIT License | 4 votes |
/** Configures propagation for {@link #USER_NAME}, using the remote header "user_name" */ @Bean Propagation.Factory propagationFactory() { return BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.newBuilder(USER_NAME).addKeyName("user_name").build()) .build(); }
Example #17
Source File: TracingConfiguration.java From brave-webmvc-example with MIT License | 4 votes |
/** Configures propagation for {@link #USER_NAME}, using the remote header "user_name" */ @Bean Propagation.Factory propagationFactory() { return BaggagePropagation.newFactoryBuilder(B3Propagation.FACTORY) .add(SingleBaggageField.newBuilder(USER_NAME).addKeyName("user_name").build()) .build(); }
Example #18
Source File: StackdriverTraceAutoConfiguration.java From spring-cloud-gcp with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public BaggagePropagation.FactoryBuilder baggagePropagationFactoryBuilder() { return BaggagePropagation.newFactoryBuilder(StackdriverTracePropagation.newFactory( B3Propagation.newFactoryBuilder().injectFormat(B3Propagation.Format.MULTI).build())); }
Example #19
Source File: ExtraFieldPropagation.java From brave with Apache License 2.0 | 4 votes |
FactoryBuilder(Propagation.Factory delegate) { this.delegate = delegate; this.baggageFactory = BaggagePropagation.newFactoryBuilder(delegate); }
Example #20
Source File: WebClientTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Bean BaggagePropagation.FactoryBuilder baggagePropagationFactoryBuilder() { // Use b3 single format as it is less verbose return BaggagePropagation.newFactoryBuilder(B3Propagation.newFactoryBuilder() .injectFormat(CLIENT, SINGLE_NO_PARENT).build()); }
Example #21
Source File: TraceBaggageConfiguration.java From spring-cloud-sleuth with Apache License 2.0 | 2 votes |
/** * To override the underlying context format, override this bean and set the delegate * to what you need. {@link BaggagePropagation.FactoryBuilder} will unwrap itself if * no fields are configured. * * <p> * This will use {@link B3Propagation.Format#SINGLE_NO_PARENT} for non-remote spans, * such as for messaging. Note: it will still parse incoming multi-header spans. */ @Bean @ConditionalOnMissingBean BaggagePropagation.FactoryBuilder baggagePropagationFactoryBuilder() { return BaggagePropagation.newFactoryBuilder(B3_FACTORY); }