Search in sources :

Example 1 with BaggageSpanProcessor

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());
}
Also used : BaggageSpanProcessor(io.honeycomb.opentelemetry.sdk.trace.spanprocessors.BaggageSpanProcessor) DeterministicTraceSampler(io.honeycomb.opentelemetry.sdk.trace.samplers.DeterministicTraceSampler)

Example 2 with 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");
    }
}
Also used : BaggageSpanProcessor(io.honeycomb.opentelemetry.sdk.trace.spanprocessors.BaggageSpanProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

BaggageSpanProcessor (io.honeycomb.opentelemetry.sdk.trace.spanprocessors.BaggageSpanProcessor)2 DeterministicTraceSampler (io.honeycomb.opentelemetry.sdk.trace.samplers.DeterministicTraceSampler)1 Test (org.junit.jupiter.api.Test)1