-
Notifications
You must be signed in to change notification settings - Fork 423
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
[API] Add synchronous gauge #3029
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3029 +/- ##
==========================================
+ Coverage 87.12% 87.88% +0.76%
==========================================
Files 200 195 -5
Lines 6109 6137 +28
==========================================
+ Hits 5322 5393 +71
+ Misses 787 744 -43
|
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.
Thanks for the feature.
This is not a full review yet,
only some preliminary comments.
Please fix:
- declarations of new virtual methods using ABI version 2
- build break issues found in CI
More extensive review to follow.
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.
Thanks for the feature.
The code structure looks good to me overall.
I defer to @lalitb to check the logic around aggregation temporality in particular,
as I am not too familiar with this area.
|
||
INSTANTIATE_TEST_SUITE_P(WritableMetricStorageTestDouble, | ||
WritableMetricStorageTestFixture, | ||
::testing::Values(AggregationTemporality::kCumulative)); |
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.
Update the test here to include the delta temporality.
If I understand the relevant section of the spec correctly, Gauges (unlike UpDownCounters and Histograms) don't support a choice of temporality. |
I was thinking the same @punya. It also mentions:
if that's related. @lalitb can you please clarify if delta temporality is actually needed? |
Sorry i was not clear enough. I meant testing for temporality with last value aggregation. The current test is only doing for cumulative. |
@uuzay - Do you think we can modify the PR to restrict configuring the delta temporality for Last Value as of now - Just thrown an error at the startup if this is enabled through View or otherwise. With that, we should be good to go through this PR. Thanks for working on this, and sorry about the long wait on this. |
Hi @lalitb, I'm planning to make the necessary changes regarding the ABI macros this week. |
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
Hi @lalitb, I was thinking if SyncMetricStorage or TemporalMetricStorage constructor would be a good place. Thanks in advance. |
@uuzay Yes that should work. Another easy place could be MetricCollector::GetAggregationTemporality. This part of code is called for both periodic reader and Prometheus, so should cover all exporters, and also in future when we support Delta for Prometheus. |
@uuzay Please merge a recent main into this PR, to get the merge conflict resolved. |
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. Thanks for working on 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.
LGTM, thanks for the feature.
/** | ||
* Record a value | ||
* | ||
* @param value The measurement value. May be positive, negative or zero. |
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.
not blocking the merge. Seems T
should be integer or float types? If so, could it be asserted explicitly like below?
static_assert(std::is_same_v<T, int64_t> || std::is_same_v<T, double>, "Gauge<T> can only be instantiated with int64_t or double");
@@ -19,6 +19,7 @@ enum class InstrumentType | |||
kCounter, | |||
kHistogram, | |||
kUpDownCounter, | |||
kGauge, |
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.
Is inserting a new InstrumentType
of kGauge
a SDK breaking change and also break the ABI? Should it be included only for OPENTELEMETRY_ABI_VERSION_NO >= 2
?
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.
It won't be ABI breaking for API, as InstrumentType
is not part of API surface. And we don't guarantee SDK ABI compatibility. It could be breaking change for custom exporters which use the switch
on this enum
without handling default
case, but this can be added in the changelog.
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 has been discussed before:
The code as written is fine:
- no change in the API, this kGauge is part of the SDK
- the SDK ABI is changed, and we do not guarantee SDK ABI compatibility
I don't think we should document that in the changelog for the SDK, by definition every SDK change can (and most of the time does) break the SDK ABI.
@ThomsonTan Please remove the change requested then, as this blocks the merge.
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.
Want to make sure if the adding of kGauge
is ABI breaking change.
Apologize for blocking the PR. I think this is the exactly the issue I raised before. The user application builds fine with either new SDK headers/old SDK libs, or old SDK headers/new SDK libs, either one will trigger a runtime break which is very hard to investigate like memory corruption. It is true that the SDK doesn't guarantee ABI compatibility, but we don't need break this if not necessary. In this specific case, either wrap the new Even it is documented that SDK doesn't support ABI combability, it may be ignored by common users as this actually works in most of the time. A better solution will be that we check the SDK version and SDK lib version, and raise error (like block linking) if both versions mismatch. How to you think? |
The only way for this to happen is to link dynamically with a shared library/DLL for the SDK itself, using a library from a different version compared to header files used during the application build. Any application compiling the with the SDK header files and linking statically with the matching SDK library will be just fine. Wrapping kGauge with ifdef causes another list of issues as well, because user code may break as well if not using the same ifdef. I think that we can move kGauge at the end of the enum, to minimize binary compatibility issues and in practice avoid breaks for this case alone. |
Move kGauge to the end, for better ABI compatibility.
Implemented as code review comment. @ThomsonTan PTAL. |
Looks good to me then, thanks. |
Fixes #2279
Changes
Added synchronous gauge implementation according to the specification.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes