Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions brave/src/main/java/brave/handler/MutableSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,9 @@ public void kind(@Nullable Kind kind) {
public void localServiceName(@Nullable String localServiceName) {
if (localServiceName == null || localServiceName.isEmpty()) {
this.localServiceName = null;
} else {
this.localServiceName = localServiceName;
}
this.localServiceName = localServiceName;
}

/**
Expand Down Expand Up @@ -438,8 +439,9 @@ public void localPort(int localPort) {
public void remoteServiceName(@Nullable String remoteServiceName) {
if (remoteServiceName == null || remoteServiceName.isEmpty()) {
this.remoteServiceName = null;
} else {
this.remoteServiceName = remoteServiceName;
}
this.remoteServiceName = remoteServiceName;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions brave/src/test/java/brave/handler/MutableSpanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,27 @@ class Tag {
);
}

@Test void localServiceNameCoercesEmptyToNull() {
MutableSpan span = new MutableSpan();
span.localServiceName("FavStar");
span.localServiceName("");
assertThat(span.localServiceName()).isNull();
}

@Test void localServiceNamePreservesCase() {
String expectedLocalServiceName = "FavStar";
MutableSpan span = new MutableSpan();
span.localServiceName(expectedLocalServiceName);
assertThat(span.localServiceName()).isEqualTo(expectedLocalServiceName);
}

@Test void remoteServiceNameCoercesEmptyToNull() {
MutableSpan span = new MutableSpan();
span.remoteServiceName("FavStar");
span.remoteServiceName("");
assertThat(span.remoteServiceName()).isNull();
}

@Test void remoteServiceNamePreservesCase() {
String expectedRemoteServiceName = "FavStar";
MutableSpan span = new MutableSpan();
Expand Down