Skip to content

Commit

Permalink
4.x: Replace deprecated method Span.baggage(key,value) on Span.baggag…
Browse files Browse the repository at this point in the history
…e().set(key,value)
  • Loading branch information
Captain1653 committed Aug 3, 2024
1 parent 45e0005 commit 70f5b47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class JaegerBaggageTest {
@Test
void testBaggage(){
Span span = tracer.spanBuilder("test-span").start();
Span spanWithBaggage = span.baggage("key", "value");
Optional<String> result = spanWithBaggage.baggage().get("key");
span.baggage().set("key", "value");
Optional<String> result = span.baggage().get("key");
assertThat(result.isPresent(), is(true));
assertThat(result.get(), equalTo("value"));

Expand All @@ -49,8 +49,8 @@ void testBaggage(){
@Test
void testBadBaggage(){
Span span = tracer.spanBuilder("test-bad-span").start();
assertThrows(NullPointerException.class, () -> span.baggage(null, "value"));
assertThrows(NullPointerException.class, () -> span.baggage("key", null));
assertThrows(NullPointerException.class, () -> span.baggage(null, null));
assertThrows(NullPointerException.class, () -> span.baggage().set(null, "value"));
assertThrows(NullPointerException.class, () -> span.baggage().set("key", null));
assertThrows(NullPointerException.class, () -> span.baggage().set(null, null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TestBaggageApi {
void testWritableBaggageFromSpan() {
Span span = Tracer.global().spanBuilder("otel-span").start();
WritableBaggage baggage = span.baggage();
span.baggage("keyA", "valA");
span.baggage().set("keyA", "valA");
assertThat("Assigned baggage via span is present", baggage.containsKey("keyA"), is(true));
assertThat("Assigned baggage via span value from baggage",
baggage.get("keyA"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void testActiveSpanScopeWithBaggage() {
currentJustAfterActivation.get().context().spanId(),
is(outerSpan.context().spanId()));

outerSpan.baggage("myItem", "myValue");
outerSpan.baggage().set("myItem", "myValue");
outerSpan.end();
} catch (Exception e) {
outerSpan.end(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestBaggageApi {
void testWritableBaggageFromSpan() {
Span span = io.helidon.tracing.Tracer.global().spanBuilder("otel-span").start();
WritableBaggage baggage = span.baggage();
span.baggage("keyA", "valA");
span.baggage().set("keyA", "valA");
assertThat("Assigned baggage via span is present", baggage.containsKey("keyA"), is(true));
assertThat("Assigned baggage via span value from baggage",
baggage.get("keyA"),
Expand Down

0 comments on commit 70f5b47

Please sign in to comment.