use of brave.propagation.CurrentTraceContext.ScopeDecorator in project brave by openzipkin.
the class CorrelationScopeDecoratorFactoryBeanTest method configs.
@Test
public void configs() {
context = new XmlBeans("" + "<util:constant id=\"traceId\" static-field=\"brave.baggage.BaggageFields.TRACE_ID\"/>\n" + "<bean id=\"correlationDecorator\" class=\"brave.spring.beans.CorrelationScopeDecoratorFactoryBean\">\n" + " <property name=\"builder\">\n" + " <bean class=\"brave.context.log4j12.MDCScopeDecorator\" factory-method=\"newBuilder\"/>\n" + " </property>\n" + " <property name=\"configs\">\n" + " <list>\n" + " <bean class=\"brave.spring.beans.SingleCorrelationFieldFactoryBean\">\n" + " <property name=\"baggageField\" ref=\"traceId\"/>\n" + " <property name=\"name\" value=\"X-B3-TraceId\"/>\n" + " </bean>\n" + " </list>\n" + " </property>\n" + "</bean>");
ScopeDecorator decorator = context.getBean("correlationDecorator", ScopeDecorator.class);
assertThat(decorator).extracting("field").usingRecursiveComparison().isEqualTo(SingleCorrelationField.newBuilder(TRACE_ID).name("X-B3-TraceId").build());
}
use of brave.propagation.CurrentTraceContext.ScopeDecorator in project brave by openzipkin.
the class CorrelationScopeDecoratorTest method decoratesNoop_unconfiguredFields.
/**
* When a context is in an unexpected state, save off fields and revert.
*/
@Test
public void decoratesNoop_unconfiguredFields() {
for (ScopeDecorator decorator : asList(withBaggageFieldsDecorator, onlyScopeDecorator)) {
map.put(FIELD.name(), "romeo");
map.put(FIELD_2.name(), "FO");
map.put(LOCAL_FIELD.name(), "abcd");
try (Scope scope = decorator.decorateScope(context, Scope.NOOP)) {
assertThat(scope).isNotSameAs(Scope.NOOP);
}
}
map.clear();
}
use of brave.propagation.CurrentTraceContext.ScopeDecorator in project brave by openzipkin.
the class CurrentTraceContextTest method ignoresNoopScopeDecorator.
@Test
public void ignoresNoopScopeDecorator() {
ScopeDecorator one = (context, scope) -> scope;
CurrentTraceContext shouldHaveOnlyOne = newBuilder().addScopeDecorator(ScopeDecorator.NOOP).addScopeDecorator(one).build();
assertThat(shouldHaveOnlyOne).extracting("scopeDecorators").asInstanceOf(InstanceOfAssertFactories.ARRAY).doesNotContain(ScopeDecorator.NOOP);
}
Aggregations