use of io.honeycomb.opentelemetry.sdk.trace.spanprocessors.BaggageSpanProcessor in project honeycomb-opentelemetry-java by honeycombio.
the class HoneycombSdkTracerProviderConfigurer method configure.
@Override
public void configure(SdkTracerProviderBuilder tracerProvider, ConfigProperties config) {
int sampleRate;
try {
sampleRate = EnvironmentConfiguration.getSampleRate();
} catch (NumberFormatException e) {
System.err.println("WARN: Sample rate provided is not an integer, using default sample rate of 1");
sampleRate = 1;
}
tracerProvider.setSampler(new DeterministicTraceSampler(sampleRate)).addSpanProcessor(new BaggageSpanProcessor());
}
use of io.honeycomb.opentelemetry.sdk.trace.spanprocessors.BaggageSpanProcessor in project honeycomb-opentelemetry-java by honeycombio.
the class BaggageSpanProcessorTest method test_baggageSpanProcessor_adds_attributes_to_spans.
@Test
public void test_baggageSpanProcessor_adds_attributes_to_spans(@Mock ReadWriteSpan span) {
try (BaggageSpanProcessor processor = new BaggageSpanProcessor()) {
AttributeKey<String> attr = AttributeKey.stringKey("key");
Baggage.current().toBuilder().put(attr.getKey(), "value").build().makeCurrent();
processor.onStart(Context.current(), span);
verify(span).setAttribute("key", "value");
}
}
Aggregations