Update java context propagation example to use Context.wrap (#4442)
Co-authored-by: Severin Neumann <neumanns@cisco.com>
This commit is contained in:
parent
0c7609a37a
commit
e39900a9c0
|
|
@ -988,14 +988,12 @@ The following example demonstrates how to propagate the context between threads:
|
|||
|
||||
```java
|
||||
io.opentelemetry.context.Context context = io.opentelemetry.context.Context.current();
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
Thread thread = new Thread(context.wrap(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try (Scope scope = context.makeCurrent()) {
|
||||
// Code for which you want to propagate the context
|
||||
}
|
||||
// Code for which you want to propagate the context
|
||||
}
|
||||
});
|
||||
}));
|
||||
thread.start();
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue