File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -244,15 +244,15 @@ async function doWork() {
244
244
using parent = tracer .startActiveSpan (" parent" );
245
245
// do some work that 'parent' tracks
246
246
console .log (" doing some work..." );
247
- const anotherWorkPromise = doAnotherWork ();
247
+ await doSomeWork ();
248
248
// Create a nested span to track nested work
249
249
{
250
250
using child = tracer .startActiveSpan (" child" );
251
251
// do some work that 'child' tracks
252
- console .log (" doing some nested work..." )
252
+ console .log (" doing some nested child work..." )
253
253
// the nested span is closed when it's out of scope
254
254
}
255
- await anotherWorkPromise ;
255
+ await doAnotherWork () ;
256
256
// This parent span is also closed when it goes out of scope
257
257
}
258
258
```
@@ -287,14 +287,16 @@ class Tracer {
287
287
```
288
288
289
289
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:
293
292
294
293
```
295
294
⌌----------⌍
296
295
| 'parent' |
297
296
⌎----------⌏
297
+ | ⌌-----------------⌍
298
+ |---| 'doSomeWork' |
299
+ | ⌎-----------------⌏
298
300
| ⌌---------⌍
299
301
|---| 'child' |
300
302
| ⌎---------⌏
You can’t perform that action at this time.
0 commit comments