use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class W3CBaggagePropagatorTest method extract_value_multiple_empty.
@Test
void extract_value_multiple_empty() {
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Context result = propagator.extract(Context.root(), ImmutableMap.of("baggage", "key1=,key1=val"), getter);
Baggage expectedBaggage = Baggage.builder().put("key1", "val").build();
assertThat(Baggage.fromContext(result)).isEqualTo(expectedBaggage);
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class JaegerPropagatorTest method inject_baggageOnly.
@Test
void inject_baggageOnly() {
// Metadata won't be propagated, but it MUST NOT cause ay problem.
Baggage baggage = Baggage.builder().put("nometa", "nometa-value").put("meta", "meta-value", BaggageEntryMetadata.create("somemetadata; someother=foo")).build();
Map<String, String> carrier = new LinkedHashMap<>();
jaegerPropagator.inject(Context.root().with(baggage), carrier, Map::put);
assertThat(carrier).containsExactlyInAnyOrderEntriesOf(ImmutableMap.of(BAGGAGE_PREFIX + "nometa", "nometa-value", BAGGAGE_PREFIX + "meta", "meta-value"));
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class OtTracePropagatorTest method extract_Baggage.
@Test
void extract_Baggage() {
Map<String, String> carrier = new LinkedHashMap<>();
carrier.put(OtTracePropagator.TRACE_ID_HEADER, TRACE_ID);
carrier.put(OtTracePropagator.SPAN_ID_HEADER, SPAN_ID);
carrier.put(OtTracePropagator.SAMPLED_HEADER, Common.TRUE_INT);
carrier.put(OtTracePropagator.PREFIX_BAGGAGE_HEADER + "foo", "bar");
carrier.put(OtTracePropagator.PREFIX_BAGGAGE_HEADER + "key", "value");
Context context = propagator.extract(Context.current(), carrier, getter);
Baggage expectedBaggage = Baggage.builder().put("foo", "bar").put("key", "value").build();
assertThat(Baggage.fromContext(context)).isEqualTo(expectedBaggage);
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class AttributesProcessorTest method appendBaggage_doesNotOverrideExistingKeys.
@Test
public void appendBaggage_doesNotOverrideExistingKeys() {
AttributesProcessor processor = AttributesProcessor.appendBaggageByKeyName(ignored -> true);
Baggage baggage = Baggage.builder().put("test", "drop").build();
Context context = Context.root().with(baggage);
assertThat(processor.process(Attributes.builder().put("test", "keep").build(), context)).hasSize(1).containsEntry("test", "keep");
}
use of io.opentelemetry.api.baggage.Baggage in project jambalaya by tailrocks.
the class TenancyUtilsTests method test1.
@Test
void test1() {
// GIVEN:
String tenant = "test";
// WHEN:
Context context = TenancyUtils.setTenantString(tenant);
// THEN:
assertNotNull(context);
// WHEN:
Baggage baggage = Baggage.fromContextOrNull(context);
// THEN:
assertNotNull(baggage);
assertNotNull(baggage.getEntryValue("tenant"));
assertEquals("dGVzdA", baggage.getEntryValue("tenant"));
}
Aggregations