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

Commit 0eb545f

Browse files
authored
Clean-up README
1 parent 594b23c commit 0eb545f

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

jaeger-core/README.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -145,39 +145,31 @@ Tracer tracer = configuration
145145
The Jaeger Java Client supports log correlation by updating the logging context (MDC) with
146146
three variables: `traceId`, `spanId`, `sampled`.
147147

148-
To accomplish that Jaegar Tracer should be created with the following two steps:
149-
150-
1. Create the MDCScopeManager using either default MDC field names:
151-
152-
```java
153-
MDCScopeManager scopeManager = new MDCScopeManager.Builder().build()
154-
```
155-
Or by providing optional custom names:
156-
157-
```java
158-
MDCScopeManager scopeManager = new MDCScopeManager
159-
.Builder()
160-
.withMDCTraceIdKey("CustomTraceId")
161-
.withMDCSampledKey("customSampled")
162-
.withMDCSpanIdKey("customSpanId")
163-
.build();
164-
```
165-
2. Create the Jaegar Tracer by supplying the MDCScopeManager created step 1:
148+
To accomplish that, first create the MDCScopeManager using either default MDC field names:
149+
166150
```java
167-
JaegerTracer.Builder("serviceName").withScopeManager(scopeManager).build();
151+
MDCScopeManager scopeManager = new MDCScopeManager.Builder().build()
152+
```
153+
154+
or with optional custom field names:
155+
156+
```java
157+
MDCScopeManager scopeManager = new MDCScopeManager
158+
.Builder()
159+
.withMDCTraceIdKey("CustomTraceId")
160+
.withMDCSampledKey("customSampled")
161+
.withMDCSpanIdKey("customSpanId")
162+
.build();
168163
```
169-
In order to have the trace info in the logs, a logging system offers MDC functionality such as log4j
170-
needs to be configured with an appender containing a proper PatternLayout.
171164

172-
For example the following code:
165+
Then instantiate the Jaegar Tracer with the MDCScopeManager:
173166
```java
174-
Span parentSpan = tracer.buildSpan("log example").start();
175-
try (Scope scope = tracer.activateSpan(parentSpan)) {
176-
LOGGER.debug("Debug with trace context!!!");
177-
}
178-
}
167+
JaegerTracer.Builder("serviceName").withScopeManager(scopeManager).build();
179168
```
180-
With this log4j2.xml configuration:
169+
In order to have the trace info in the logs, a logging system that offers MDC functionality, such as log4j,
170+
needs to be configured with an appender containing a proper PatternLayout.
171+
172+
For example, this log4j2.xml configuration:
181173
```xml
182174
<?xml version="1.0" encoding="UTF-8"?>
183175
<Configuration status="INFO">
@@ -194,8 +186,12 @@ With this log4j2.xml configuration:
194186
</Loggers>
195187
</Configuration>
196188
```
197-
Prints:
198-
[DEBUG] 2020-06-28 22:25:07.152 [main] LogExample - Debug with trace context!!!% traceId=729b37ccf9c1549d spanId=729b37ccf9c1549d sampled=false
189+
190+
might produce a lot line like this:
191+
192+
```
193+
[DEBUG] 2020-06-28 22:25:07.152 [main] LogExample - Your log message traceId=729b37ccf9c1549d spanId=729b37ccf9c1549d sampled=false
194+
```
199195

200196
## Development
201197

0 commit comments

Comments
 (0)