Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Restore support for setting null as a tag value (Resolves #823) (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhadadi authored Jan 4, 2022
1 parent c92da42 commit 0dafe38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected JaegerSpan(
this.startTimeMicroseconds = startTimeMicroseconds;
this.startTimeNanoTicks = startTimeNanoTicks;
this.computeDurationViaNanoTicks = computeDurationViaNanoTicks;
this.tags = new ConcurrentHashMap<String, Object>();
this.tags = new ConcurrentHashMap<>();
this.references = references != null ? new ArrayList<Reference>(references) : null;

// Handle SAMPLING_PRIORITY tag first, as this influences whether setTagAsObject actually
Expand Down Expand Up @@ -111,7 +111,7 @@ public List<Reference> getReferences() {
}

public Map<String, Object> getTags() {
return new HashMap<String, Object>(tags);
return new HashMap<>(tags);
}

@Override
Expand Down Expand Up @@ -225,7 +225,7 @@ private JaegerSpan setTagAsObject(String key, Object value) {
}

if (context.isSampled()) {
tags.put(key, value);
tags.put(key, value == null ? "null" : value);
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ public void testSetAndGetBaggageItem() {
assertEquals(value, jaegerSpan.getBaggageItem(key));
}

@Test
public void testSetNullTag() {
String key = "tag.key";

jaegerSpan.setTag(key, (String)null);
assertEquals("null", jaegerSpan.getTags().get(key));
}

@Test
public void testSetBooleanTag() {
Boolean expected = true;
Expand Down

0 comments on commit 0dafe38

Please sign in to comment.