-
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.
Merge pull request #135 from mathworks/exampletests
Adding tests for examples
- Loading branch information
Showing
11 changed files
with
532 additions
and
79 deletions.
There are no files selected for viewing
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
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,38 @@ | ||
classdef async_metrics_example_callbacks < handle | ||
% Callback functions for asynchronous metrics example | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
properties | ||
Count | ||
UpDownCount | ||
end | ||
|
||
methods | ||
function obj = async_metrics_example_callbacks() | ||
obj.Count = 0; | ||
obj.UpDownCount = 0; | ||
end | ||
|
||
function result = counterCallback(obj) | ||
% Callback function for Counter | ||
obj.Count = obj.Count + randi(10); % increment between 0 and 10 | ||
result = opentelemetry.metrics.ObservableResult; | ||
result = result.observe(obj.Count); | ||
end | ||
|
||
function result = updowncounterCallback(obj) | ||
% Callback function for UpdownCounter | ||
obj.UpDownCount = obj.UpDownCount + randi([-5 5]); % increment between -5 to 5 | ||
result = opentelemetry.metrics.ObservableResult; | ||
result = result.observe(obj.UpDownCount); | ||
end | ||
|
||
function result = gaugeCallback(~) | ||
% Callback function for Gauge | ||
s = second(datetime("now")); % get the current second of the minute | ||
result = opentelemetry.metrics.ObservableResult; | ||
result = result.observe(s); | ||
end | ||
end | ||
end |
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
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
Oops, something went wrong.