Skip to content

Commit

Permalink
fix wrong context propagated to callback of traceContext and traceCon…
Browse files Browse the repository at this point in the history
…textSync
  • Loading branch information
blakeroberts-wk committed Oct 15, 2024
1 parent 9d7a386 commit 87ed449
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export 'src/api/context/context.dart'
attach,
Context,
ContextKey,
contextFromZone,
contextWithSpan,
contextWithSpanContext,
detach,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/api/open_telemetry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Future<T> traceContext<T>(String name, Future<T> Function(api.Context) fn,
bool newRoot = false,
api.SpanKind spanKind = api.SpanKind.internal,
List<api.SpanLink> spanLinks = const []}) async {
return trace(name, () => fn(context ?? api.active),
return trace(name, () => fn(api.contextFromZone()),
context: context,
tracer: tracer,
newRoot: newRoot,
Expand All @@ -65,7 +65,7 @@ T traceContextSync<T>(String name, T Function(api.Context) fn,
bool newRoot = false,
api.SpanKind spanKind = api.SpanKind.internal,
List<api.SpanLink> spanLinks = const []}) {
return traceSync(name, () => fn(context ?? api.active),
return traceSync(name, () => fn(api.contextFromZone()),
context: context,
tracer: tracer,
newRoot: newRoot,
Expand Down

0 comments on commit 87ed449

Please sign in to comment.