Skip to content

Commit

Permalink
add span attributes optional named parameter to trace helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeroberts-wk committed Jan 8, 2025
1 parent b4dd92b commit 441324e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/api/open_telemetry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Future<T> trace<T>(String name, Future<T> Function() fn,
{api.Context? context,
api.Tracer? tracer,
bool newRoot = false,
List<api.Attribute> spanAttributes = const [],
api.SpanKind spanKind = api.SpanKind.internal,
List<api.SpanLink> spanLinks = const []}) async {
context ??= api.Context.current;
Expand All @@ -89,6 +90,7 @@ Future<T> trace<T>(String name, Future<T> Function() fn,
final span = tracer.startSpan(name,
// TODO: use start span option `newRoot` instead
context: newRoot ? api.Context.root : context,
attributes: spanAttributes,
kind: spanKind,
links: spanLinks);
try {
Expand Down Expand Up @@ -116,6 +118,7 @@ T traceSync<T>(String name, T Function() fn,
{api.Context? context,
api.Tracer? tracer,
bool newRoot = false,
List<api.Attribute> spanAttributes = const [],
api.SpanKind spanKind = api.SpanKind.internal,
List<api.SpanLink> spanLinks = const []}) {
context ??= api.Context.current;
Expand All @@ -124,6 +127,7 @@ T traceSync<T>(String name, T Function() fn,
final span = tracer.startSpan(name,
// TODO: use start span option `newRoot` instead
context: newRoot ? api.Context.root : context,
attributes: spanAttributes,
kind: spanKind,
links: spanLinks);
try {
Expand Down

0 comments on commit 441324e

Please sign in to comment.