-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for combining auto and manual instrumentation and clean up…
… AutoTrace test examples
- Loading branch information
Showing
14 changed files
with
195 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...totrace_examples/example1/best_fit_line.m → ...xamples/linearfit_example/best_fit_line.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...totrace_examples/example1/generate_data.m → ...xamples/linearfit_example/generate_data.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test/autotrace_examples/example1/example1.m → ...les/linearfit_example/linearfit_example.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ace_examples/example1/example1_trycatch.m → ...rfit_example/linearfit_example_trycatch.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
test/autotrace_examples/manual_instrumented_example/best_fit_line.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function yf = best_fit_line(x, y) | ||
% Fit a straight line on input data and manually start and end two spans. | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
tr = opentelemetry.trace.getTracer("ManualInstrument"); | ||
|
||
sp1 = startSpan(tr, "polyfit"); | ||
coefs = polyfit(x, y, 1); | ||
endSpan(sp1); | ||
|
||
sp2 = startSpan(tr, "polyval"); | ||
yf = polyval(coefs , x); | ||
endSpan(sp2); |
22 changes: 22 additions & 0 deletions
22
test/autotrace_examples/manual_instrumented_example/generate_data.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function [x, y] = generate_data(n) | ||
% Generate random data with n data points and manually start and end a span. | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
% check input is valid | ||
if ~(isnumeric(n) && isscalar(n)) | ||
error("autotrace_examples:linearfit_example:generate_data:InvalidN", ... | ||
"Input must be a numeric scalar"); | ||
end | ||
|
||
% generate some random data | ||
a = 1.5; | ||
b = 0.8; | ||
sigma = 5; | ||
x = 1:n; | ||
|
||
% start a span | ||
tr = opentelemetry.trace.getTracer("ManualInstrument"); | ||
sp = startSpan(tr, "compute_y"); | ||
y = a * x + b + sigma * randn(1, n); | ||
endSpan(sp); |
8 changes: 8 additions & 0 deletions
8
test/autotrace_examples/manual_instrumented_example/manual_instrumented_example.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function yf = manual_instrumented_example(n) | ||
% Example code for testing auto and manual instrumentation together. | ||
% Input n is the number of data points. | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
[x, y] = generate_data(n); | ||
yf = best_fit_line(x,y); |
6 changes: 6 additions & 0 deletions
6
test/autotrace_examples/subfolder_example/helpers/subfolder_helper1.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function x = subfolder_helper1(x) | ||
% example code for testing auto instrumentation, helper function | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
x = x * 2; |
6 changes: 6 additions & 0 deletions
6
test/autotrace_examples/subfolder_example/helpers/subfolder_helper2.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function x = subfolder_helper2(x) | ||
% example code for testing auto instrumentation, helper function | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
x = x * 3; |
10 changes: 10 additions & 0 deletions
10
test/autotrace_examples/subfolder_example/subfolder_example.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function x = subfolder_example | ||
% Example code for testing auto instrumentation, with some helper functions | ||
% in a subfolder | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
x = 10; | ||
x = subfolder_helper1(x); | ||
x = subfolder_helper2(x); | ||
|
Oops, something went wrong.