Skip to content

Commit

Permalink
support long, double and boolean for tags #234
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikita Karaliou committed Apr 18, 2023
1 parent dd22826 commit 3decdd8
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ public Span tag(String key, String value) {
return this;
}

@Override
public Span tag(String key, long value) {
this.delegate.tag(key, String.valueOf(value));
return this;
}

@Override
public Span tag(String key, double value) {
this.delegate.tag(key, String.valueOf(value));
return this;
}

@Override
public Span tag(String key, boolean value) {
this.delegate.tag(key, String.valueOf(value));
return this;
}

@Override
public Span error(Throwable throwable) {
String message = throwable.getMessage() == null ? throwable.getClass().getSimpleName() : throwable.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ public Span tag(String key, String value) {
return new OtelSpan(this.delegate);
}

@Override
public Span tag(String key, long value) {
this.delegate.setAttribute(key, value);
return new OtelSpan(this.delegate);
}

@Override
public Span tag(String key, double value) {
this.delegate.setAttribute(key, value);
return new OtelSpan(this.delegate);
}

@Override
public Span tag(String key, boolean value) {
this.delegate.setAttribute(key, value);
return new OtelSpan(this.delegate);
}

@Override
public void end(long time, TimeUnit timeUnit) {
this.delegate.end(time, timeUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ public SimpleSpan tag(String key, String value) {
return this;
}

@Override
public Span tag(String key, long value) {
this.tags.put(key, String.valueOf(value));
return this;
}

@Override
public Span tag(String key, double value) {
this.tags.put(key, String.valueOf(value));
return this;
}

@Override
public Span tag(String key, boolean value) {
this.tags.put(key, String.valueOf(value));
return this;
}

@Override
public SimpleSpan error(Throwable throwable) {
this.throwable = throwable;
Expand Down
21 changes: 21 additions & 0 deletions micrometer-tracing/src/main/java/io/micrometer/tracing/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ public Span tag(String key, String value) {
return this;
}

@Override
public Span tag(String key, long value) {
return this;
}

@Override
public Span tag(String key, double value) {
return this;
}

@Override
public Span tag(String key, boolean value) {
return this;
}

@Override
public Span error(Throwable throwable) {
return this;
Expand Down Expand Up @@ -151,6 +166,12 @@ public Span remoteIpAndPort(String ip, int port) {
*/
Span tag(String key, String value);

Span tag(String key, long value);

Span tag(String key, double value);

Span tag(String key, boolean value);

/**
* Records an exception for this span.
* @param throwable to record
Expand Down

0 comments on commit 3decdd8

Please sign in to comment.