Skip to content

Commit

Permalink
[zipkin span] ensure span tags are string only otherwise zipkin rejec…
Browse files Browse the repository at this point in the history
…ts them without a converter step
  • Loading branch information
rmannibucau committed Sep 7, 2023
1 parent 53d628f commit b75b366
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
<properties>
<maven.compiler.java.version>11</maven.compiler.java.version>

<xbean.version>4.22</xbean.version>
<xbean.version>4.23</xbean.version>
<owb.version>2.0.27</owb.version>
<tomcat.version>10.1.13</tomcat.version>
<johnzon.version>1.2.19</johnzon.version>
<johnzon.version>1.2.21</johnzon.version>

<!-- for quarkus only -->
<netty.version>4.1.77.Final</netty.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public RequestListener.State<State> before(final long count, final HttpRequest r
tags.putIfAbsent("http.url", request.uri().toASCIIString());
tags.putIfAbsent("http.method", request.method());
tags.putIfAbsent("peer.hostname", request.uri().getHost());
tags.putIfAbsent("peer.port", request.uri().getPort());
tags.putIfAbsent("peer.port", Integer.toString(request.uri().getPort()));

final var endpoint = new Span.Endpoint();
endpoint.setServiceName(configuration.getServiceName());
Expand Down Expand Up @@ -112,7 +112,7 @@ private String ipOf(final String host) {
@Override
public void after(final State state, final HttpRequest request, final Throwable error, final HttpResponse<?> response) {
if (response != null) {
state.span.getTags().putIfAbsent("http.status", response.statusCode());
state.span.getTags().putIfAbsent("http.status", Integer.toString(response.statusCode()));
}
if (error != null) {
state.span.getTags().putIfAbsent("http.error", error.getMessage() == null ? error.getClass().getName() : error.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected void addErrorTag(final Map<String, Object> tags, final Throwable throw

protected void finish(final HttpServletResponse response, final Span span, final Instant start) {
final var end = clock.instant();
span.getTags().putIfAbsent("http.status", response.getStatus());
span.getTags().putIfAbsent("http.status", Integer.toString(response.getStatus()));
span.setDuration(TimeUnit.MILLISECONDS.toMicros(end.minusMillis(start.toEpochMilli()).toEpochMilli()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ void trace() {
"component", "yupiik-httpclient",
"http.method", "GET",
"http.url", "http://localhost/foo?bar=dummy",
"http.status", 123,
"http.status", "123",
"peer.hostname", "localhost",
"peer.port", -1
"peer.port", "-1"
), span1.getTags());
assertNotNull(span1.getTimestamp());
assertNotNull(span1.getDuration());
Expand Down Expand Up @@ -117,9 +117,9 @@ void traceWithParent() {
"component", "yupiik-httpclient",
"http.method", "GET",
"http.url", "http://localhost/foo?bar=dummy",
"http.status", 123,
"http.status", "123",
"peer.hostname", "localhost",
"peer.port", -1
"peer.port", "-1"
), span1.getTags());
assertNotNull(span1.getTimestamp());
assertNotNull(span1.getDuration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void invoke(final Request request, final Response response) throws IOExce
"component", "tomcat",
"http.method", "GET",
"http.url", "/test",
"http.status", 200
"http.status", "200"
), span1.getTags());
assertNotNull(span1.getTimestamp());
assertNotNull(span1.getDuration());
Expand All @@ -145,7 +145,7 @@ public void invoke(final Request request, final Response response) throws IOExce
"component", "tomcat",
"http.method", "GET",
"http.url", "/async-test",
"http.status", 200
"http.status", "200"
), span2.getTags());
assertNotNull(span2.getTimestamp());
assertNotNull(span2.getDuration());
Expand Down

0 comments on commit b75b366

Please sign in to comment.