Skip to content

Commit 397e4f0

Browse files
committed
Add error message to span error status description. Closes #167
1 parent 961c824 commit 397e4f0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

auto-instrumentation/+opentelemetry/+autoinstrument/AutoTrace.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function handleError(obj, ME)
150150
% spans and their corresponding scopes. Rethrow the
151151
% exception ME.
152152
if ~isempty(obj.Instrumentor.Spans)
153-
setStatus(obj.Instrumentor.Spans(end), "Error");
153+
setStatus(obj.Instrumentor.Spans(end), "Error", ME.message);
154154
for i = length(obj.Instrumentor.Spans):-1:1
155155
obj.Instrumentor.Spans(i) = [];
156156
obj.Instrumentor.Scopes(i) = [];
@@ -195,4 +195,4 @@ function handleError(obj, ME)
195195
% file
196196
f = processFileInput(f);
197197
end
198-
end
198+
end

test/tautotrace.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ function testError(testCase)
253253

254254
% check error status
255255
verifyEqual(testCase, results{1}.resourceSpans.scopeSpans.spans.status.code, 2); % error
256+
verifyEqual(testCase, results{1}.resourceSpans.scopeSpans.spans.status.message, ...
257+
'Input must be a numeric scalar');
256258
verifyEmpty(testCase, fieldnames(results{2}.resourceSpans.scopeSpans.spans.status)); % ok, no error
257259
end
258260

@@ -287,6 +289,8 @@ function testHandleError(testCase)
287289

288290
% check error status
289291
verifyEqual(testCase, results{1}.resourceSpans.scopeSpans.spans.status.code, 2); % error
292+
verifyEqual(testCase, results{1}.resourceSpans.scopeSpans.spans.status.message, ...
293+
'Input must be a numeric scalar');
290294
verifyEmpty(testCase, fieldnames(results{2}.resourceSpans.scopeSpans.spans.status)); % ok, no error
291295
end
292296

0 commit comments

Comments
 (0)