Update java context propagation example to use Context.wrap (#4442)

Co-authored-by: Severin Neumann <neumanns@cisco.com>
This commit is contained in:
jack-berg 2024-05-08 03:00:26 -05:00 committed by GitHub
parent 0c7609a37a
commit e39900a9c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 5 deletions

View File

@ -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();
```