Skip to content

Commit e39900a

Browse files
jack-bergsvrnm
andauthored
Update java context propagation example to use Context.wrap (#4442)
Co-authored-by: Severin Neumann <[email protected]>
1 parent 0c7609a commit e39900a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: content/en/docs/languages/java/instrumentation.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -988,14 +988,12 @@ The following example demonstrates how to propagate the context between threads:
988988

989989
```java
990990
io.opentelemetry.context.Context context = io.opentelemetry.context.Context.current();
991-
Thread thread = new Thread(new Runnable() {
991+
Thread thread = new Thread(context.wrap(new Runnable() {
992992
@Override
993993
public void run() {
994-
try (Scope scope = context.makeCurrent()) {
995-
// Code for which you want to propagate the context
996-
}
994+
// Code for which you want to propagate the context
997995
}
998-
});
996+
}));
999997
thread.start();
1000998
```
1001999

0 commit comments

Comments
 (0)