brave.baggage.BaggagePropagationConfig Java Examples

The following examples show how to use brave.baggage.BaggagePropagationConfig. 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: AWSPropagationTest.java    From zipkin-aws with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: SingleBaggageFieldFactoryBeanTest.java    From brave with Apache License 2.0 6 votes vote down vote up
@Test public void allProperties() {
  context = new XmlBeans(""
    + "<bean id=\"userId\" class=\"brave.baggage.BaggageField\" factory-method=\"create\">\n"
    + "  <constructor-arg><value>userId</value></constructor-arg>\n"
    + "</bean>\n"
    + "<bean id=\"userIdBaggageConfig\" class=\"brave.spring.beans.SingleBaggageFieldFactoryBean\">\n"
    + "  <property name=\"field\" ref=\"userId\"/>\n"
    + "  <property name=\"keyNames\">\n"
    + "    <list>\n"
    + "      <value>user-id</value>\n"
    + "    </list>\n"
    + "  </property>\n"
    + "</bean>\n"
  );

  assertThat(context.getBean("userIdBaggageConfig", BaggagePropagationConfig.class))
    .usingRecursiveComparison()
    .isEqualTo(SingleBaggageField.newBuilder(BaggageField.create("userId"))
      .addKeyName("user-id")
      .build());
}
 
Example #3
Source File: BaggagePropagationFactoryBean.java    From brave with Apache License 2.0 5 votes vote down vote up
@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 #4
Source File: SingleBaggageFieldFactoryBeanTest.java    From brave with Apache License 2.0 5 votes vote down vote up
@Test public void leastProperties() {
  context = new XmlBeans(""
    + "<bean id=\"userId\" class=\"brave.baggage.BaggageField\" factory-method=\"create\">\n"
    + "  <constructor-arg><value>userId</value></constructor-arg>\n"
    + "</bean>\n"
    + "<bean id=\"userIdBaggageConfig\" class=\"brave.spring.beans.SingleBaggageFieldFactoryBean\">\n"
    + "  <property name=\"field\" ref=\"userId\"/>\n"
    + "</bean>\n"
  );

  assertThat(context.getBean("userIdBaggageConfig", BaggagePropagationConfig.class))
    .usingRecursiveComparison()
    .isEqualTo(SingleBaggageField.local(BaggageField.create("userId")));
}
 
Example #5
Source File: MultipleHopsIntegrationTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@Bean
BaggagePropagationConfig notInProperties() {
	return SingleBaggageField.remote(BaggageField.create("bar"));
}
 
Example #6
Source File: SingleBaggageFieldFactoryBean.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public Class<? extends BaggagePropagationConfig> getObjectType() {
  return BaggagePropagationConfig.class;
}
 
Example #7
Source File: BaggagePropagationFactoryBean.java    From brave with Apache License 2.0 4 votes vote down vote up
public void setConfigs(List<BaggagePropagationConfig> configs) {
  this.configs = configs;
}