Skip to content

Commit ef7043e

Browse files
committed
Update an example
1 parent 7324d8e commit ef7043e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ async function doWork() {
244244
using parent = tracer.startActiveSpan("parent");
245245
// do some work that 'parent' tracks
246246
console.log("doing some work...");
247-
const anotherWorkPromise = doAnotherWork();
247+
await doSomeWork();
248248
// Create a nested span to track nested work
249249
{
250250
using child = tracer.startActiveSpan("child");
251251
// do some work that 'child' tracks
252-
console.log("doing some nested work...")
252+
console.log("doing some nested child work...")
253253
// the nested span is closed when it's out of scope
254254
}
255-
await anotherWorkPromise;
255+
await doAnotherWork();
256256
// This parent span is also closed when it goes out of scope
257257
}
258258
```
@@ -287,14 +287,16 @@ class Tracer {
287287
```
288288

289289
The semantic that doesn't mutate existing AsyncContext mapping is crucial to the
290-
`startAsCurrentSpan` example here, as it allows deferred span created in
291-
`doAnotherWork` to be a child span of the `"parent"` instead of `"child"`,
292-
shown as graph below:
290+
`startAsCurrentSpan` example here, as it allows `doAnotherWork` to be a child
291+
span of the `"parent"` instead of `"child"`, shown as graph below:
293292

294293
```
295294
⌌----------⌍
296295
| 'parent' |
297296
⌎----------⌏
297+
| ⌌-----------------⌍
298+
|---| 'doSomeWork' |
299+
| ⌎-----------------⌏
298300
| ⌌---------⌍
299301
|---| 'child' |
300302
| ⌎---------⌏

0 commit comments

Comments
 (0)