use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class W3CBaggagePropagatorTest method inject.
@Test
void inject() {
Baggage baggage = Baggage.builder().put("nometa", "nometa-value").put("needsEncoding", "blah blah blah").put("meta", "meta-value", BaggageEntryMetadata.create("somemetadata; someother=foo")).put("\2ab\3cd", "wacky key nonprintable").put(null, "null key").put("nullvalue", null).build();
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Map<String, String> carrier = new HashMap<>();
propagator.inject(Context.root().with(baggage), carrier, Map::put);
assertThat(carrier).containsExactlyInAnyOrderEntriesOf(singletonMap("baggage", "meta=meta-value;somemetadata%3B%20someother%3Dfoo,needsEncoding=blah%20blah%20blah,nometa=nometa-value"));
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class W3CBaggagePropagatorTest method extract_member_fullComplexities.
@Test
void extract_member_fullComplexities() {
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Context result = propagator.extract(Context.root(), ImmutableMap.of("baggage", "key1= value1; metadata-key = value; othermetadata, " + "key2 =value2 , key3 =\tvalue3 ; "), getter);
Baggage expectedBaggage = Baggage.builder().put("key1", "value1", BaggageEntryMetadata.create("metadata-key = value; othermetadata")).put("key2", "value2", BaggageEntryMetadata.empty()).put("key3", "value3").build();
assertThat(Baggage.fromContext(result)).isEqualTo(expectedBaggage);
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class W3CBaggagePropagatorTest method extract_member_multi.
@Test
void extract_member_multi() {
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Context result = propagator.extract(Context.root(), ImmutableMap.of("baggage", "key1=value1,key2=value2"), getter);
Baggage expectedBaggage = Baggage.builder().put("key1", "value1").put("key2", "value2").build();
assertThat(Baggage.fromContext(result)).isEqualTo(expectedBaggage);
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class W3CBaggagePropagatorTest method extract_value_urlEncoding.
@Test
void extract_value_urlEncoding() {
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Context result = propagator.extract(Context.root(), ImmutableMap.of("baggage", "key=value%201"), getter);
Baggage expectedBaggage = Baggage.builder().put("key", "value 1").build();
assertThat(Baggage.fromContext(result)).isEqualTo(expectedBaggage);
}
use of io.opentelemetry.api.baggage.Baggage in project opentelemetry-java by open-telemetry.
the class W3CBaggagePropagatorTest method extract_value_multiple_trailingSpaces.
@Test
void extract_value_multiple_trailingSpaces() {
W3CBaggagePropagator propagator = W3CBaggagePropagator.getInstance();
Context result = propagator.extract(Context.root(), ImmutableMap.of("baggage", "key=value1 ,key1=val"), getter);
Baggage expectedBaggage = Baggage.builder().put("key1", "val").put("key", "value1").build();
assertThat(Baggage.fromContext(result)).isEqualTo(expectedBaggage);
}
Aggregations