Skip to content

Commit 618e16c

Browse files
committed
add getCurrentSpan convenience function
1 parent 70cd823 commit 618e16c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function sp = getCurrentSpan()
2+
% Retrieve the current span
3+
% SP = OPENTELEMETRY.TRACE.GETCURRENTSPAN() returns the current span.
4+
% If there is not current span, SP will be an invalid span with all-zero
5+
% trace and span IDs.
6+
%
7+
% See also OPENTELEMETRY.TRACE.SPAN,
8+
% OPENTELEMETRY.CONTEXT.GETCURRENTCONTEXT
9+
% OPENTELEMETRY.TRACE.CONTEXT.EXTRACTSPAN
10+
11+
% Copyright 2024 The MathWorks, Inc.
12+
13+
ctx = opentelemetry.context.getCurrentContext;
14+
sp = opentelemetry.trace.Context.extractSpan(ctx);

test/autotrace_examples/manual_instrumented_example/manual_instrumented_example.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
% Copyright 2024 The MathWorks, Inc.
66

77
% add an attribute about input
8-
ctx = opentelemetry.context.getCurrentContext;
9-
sp = opentelemetry.trace.Context.extractSpan(ctx);
8+
sp = opentelemetry.trace.getCurrentSpan;
109
setAttributes(sp, "DataSize", n);
1110

1211
[x, y] = generate_data(n);

0 commit comments

Comments
 (0)