Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs translation when SpanTranslator is at FINE/DEBUG level #73

Merged
merged 1 commit into from
Apr 10, 2018
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
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,46 @@ yourself by downloading a couple jars.

[Here's an example](autoconfigure/storage-stackdriver#quick-start) of
integrating Stackdriver storage.

## Troubleshooting translation issues

When using a component that sends data to Stackdriver, if you see nothing in the console,
try enabling DEBUG logging on the translation component. If using Spring Boot (ex normal
app or zipkin server integration), add the following system property:

```
-Dlogging.level.zipkin2.translation.stackdriver=DEBUG
```

Note: If using our docker image or anything that uses JAVA_OPTS, you can add this there.

With this in place, you'll see the input and output of translation like below. Keep a copy
of this when contacting us on [gitter](https://gitter.im/openzipkin/zipkin) for support.

```
2018-04-09 13:58:44.112 DEBUG [/] 11325 --- [ XNIO-2 I/O-3] z.t.stackdriver.SpanTranslator : >> translating zipkin span: {"traceId":"d42316227862f939","parentId":"d42316227862f939","id":"dfbb21f9cf4c52b3","kind":"CLIENT","name":"get","timestamp":1523253523054380,"duration":4536,"localEndpoint":{"serviceName":"frontend","ipv4":"192.168.1.113"},"tags":{"http.method":"GET","http.path":"/api"}}
2018-04-09 13:58:44.113 DEBUG [/] 11325 --- [ XNIO-2 I/O-3] z.t.stackdriver.SpanTranslator : << translated to stackdriver span: span_id: 16199746076534411288
kind: RPC_CLIENT
name: "get"
start_time {
seconds: 1523253523
nanos: 54380000
}
end_time {
seconds: 1523253523
nanos: 58916000
}
parent_span_id: 15286085897530046777
labels {
key: "/http/method"
value: "GET"
}
labels {
key: "zipkin.io/http.path"
value: "/api"
}
labels {
key: "/component"
value: "frontend"
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.google.protobuf.Timestamp;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import zipkin2.Span;

/**
Expand All @@ -29,6 +31,7 @@
* server-side span. Other parent-child relationships will be preserved.
*/
public final class SpanTranslator {
private static final Logger LOG = Logger.getLogger(SpanTranslator.class.getName());

static final LabelExtractor labelExtractor;

Expand Down Expand Up @@ -58,6 +61,8 @@ public final class SpanTranslator {
* @return A Stackdriver Trace Span.
*/
public static TraceSpan.Builder translate(TraceSpan.Builder spanBuilder, Span zipkinSpan) {
boolean logTranslation = LOG.isLoggable(Level.FINE);
if (logTranslation) LOG.fine(">> translating zipkin span: " + zipkinSpan);
spanBuilder.setName(zipkinSpan.name() != null ? zipkinSpan.name() : "");
SpanKind kind = getSpanKind(zipkinSpan.kind());
spanBuilder.setKind(kind);
Expand All @@ -72,6 +77,7 @@ public static TraceSpan.Builder translate(TraceSpan.Builder spanBuilder, Span zi
}
}
spanBuilder.putAllLabels(labelExtractor.extract(zipkinSpan));
if (logTranslation) LOG.fine("<< translated to stackdriver span: " + spanBuilder);
return spanBuilder;
}

Expand Down