-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Asynchronous Metric Instruments SDK #191
Add Asynchronous Metric Instruments SDK #191
Conversation
Codecov Report
@@ Coverage Diff @@
## master #191 +/- ##
=======================================
Coverage 93.63% 93.63%
=======================================
Files 134 134
Lines 5345 5345
=======================================
Hits 5005 5005
Misses 340 340 |
} | ||
|
||
/* | ||
* Activate the intsrument's callback function to record a measurement. This |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Activate the intsrument's callback function to record a measurement. This | |
* Activate the instrument's callback function to record a measurement. This |
#include <map> | ||
#include <sstream> | ||
#include <vector> | ||
#include <memory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: would you sort includes alphabetically unless there is a good reason not to do so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format tools reorder the includes but I sorted them where I could.
} | ||
|
||
// Public mapping from labels (stored as strings) to their respective aggregators | ||
std::unordered_map<std::string, std::shared_ptr<Aggregator<T>>> boundAggregators_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be indentation issue.
else | ||
{ | ||
if (value < 0){ | ||
throw std::invalid_argument("Counter instrument updates must be non-negative."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pyohannes do you think we should check __EXCEPTIONS
and call std::terminate
?
I think we shouldn't throw if exception is disabled, however we don't want to kill the process as this is not a critical failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a check and call to terminate :)
return ret; | ||
} | ||
|
||
// Public mapping from labels (stored as strings) to their respective aggregators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be another indentation issue, would you rebase and check if the formatter CI would pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase, resolve conflicts and make sure all the GitHub Actions CI would pass.
d608f83
to
6e4cb4d
Compare
@reyang Thanks for the review! I rebased and addressed your comments. Additionally, we discovered a bug related to the way we were dealing with concurrency in our synchronous instruments. I added fixes in this PR out of convenience (you can see the changes in the |
e984a9c
to
7b76bc4
Compare
@reyang This should be ready to merge unless there are any further concerns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This PR implements the asynchronous instrument classes described in the Metric Instruments API (PR #161). These classes are capable of actually collecting telemetry data unlike no-op implementations included with the API. Instruments employ Aggregators (pending approval in PR #178 and PR #181 ) to combine the updates they receive into meaningful values.
A test suite which validates each instrument’s ability to record values in single-threaded and concurrent scenarios is included. Functions necessary for the metrics pipeline as a whole such as reference counting are tested as well.
This PR in conjunction with (PR #179) provides support for all metric instruments listed in the spec. This PR will not compile without all the other PRs mentioned in this description.
Note: We templated instruments to support a wider array of scalar types. Templating prevents us from using out of line declarations as we normally would. As a result, we left all implementation code in the header file. If there are any suggestions to remedy this we will gladly make the change. Code for the base classes which asynchronous instruments inherit from is in PR #161.