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

Commit

Permalink
Add example for logstash
Browse files Browse the repository at this point in the history
Suggested in #715 (comment)
  • Loading branch information
yurishkuro authored Aug 21, 2020
1 parent 1bb6dd2 commit cd0668f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion jaeger-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ MDCScopeManager scopeManager = new MDCScopeManager

Then instantiate the Jaegar Tracer with the MDCScopeManager:
```java
JaegerTracer.Builder("serviceName").withScopeManager(scopeManager).build();
JaegerTracer tracer = new JaegerTracer.Builder("serviceName")
.withScopeManager(scopeManager).build();
```
In order to have the trace info in the logs, a logging system that offers MDC functionality, such as log4j,
needs to be configured with an appender containing a proper PatternLayout.
Expand Down Expand Up @@ -193,6 +194,21 @@ might produce a log line like this:
[DEBUG] 2020-06-28 22:25:07.152 [main] LogExample - Your log message traceId=729b37ccf9c1549d spanId=729b37ccf9c1549d sampled=false
```

The Logstash configuration might look like this:

```xml
<appender name="jsonConsoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeMdcKeyName>traceId</includeMdcKeyName>
<includeMdcKeyName>spanId</includeMdcKeyName>
<includeMdcKeyName>sampled</includeMdcKeyName>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="jsonConsoleAppender"/>
</root>
```

## Development

Especially in unit tests, it's useful to have tracer that is not connected to tracing backend, but collects
Expand Down

0 comments on commit cd0668f

Please sign in to comment.