Skip to content
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

[Metric SDK] - Avoid exposing AttributeSet to exporters - Part1 #1792

Merged
merged 7 commits into from
May 21, 2024

Conversation

cijothomas
Copy link
Member

@cijothomas cijothomas commented May 20, 2024

AttributeSet is how attributes are stored internally for Metric Aggregation, and is also exposed to exporters. This PR exposes only a Vec<KeyValue> to exporters (done only for SUM, HISTOGRAM to keep PR's small)

In the next set of PRs, this will be extended to all Aggregations, and then AttributeSet can be completely kept pub(crate) instead of exposing it. Also, attributes can be further hidden by just exposing an Iterator only, instead of even a Vec!.

This affects some export authors. Not adding changelog in this PR, as I plan to get it covered in one shot when above are achieved.

Also removed opentelemetry-prometheus from CI for now, as it is not planned for the upcoming release : #1719

@cijothomas cijothomas requested a review from a team May 20, 2024 22:40
@cijothomas cijothomas changed the title [Metric SDK] - Avoid exposing AttributeSet to exporters [Metric SDK] - Avoid exposing AttributeSet to exporters - Part1 May 20, 2024
Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 93.61702% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 73.0%. Comparing base (5c17ed1) to head (ab8994a).

Files Patch % Lines
opentelemetry-stdout/src/metrics/transform.rs 0.0% 2 Missing ⚠️
opentelemetry-sdk/src/metrics/internal/sum.rs 95.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1792     +/-   ##
=======================================
- Coverage   74.1%   73.0%   -1.1%     
=======================================
  Files        125     121      -4     
  Lines      19481   18891    -590     
=======================================
- Hits       14452   13808    -644     
- Misses      5029    5083     +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

attributes: attrs
.iter()
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
.collect(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not worried about the extra cost here, as this is in collect() path only, to focus on fixing the hot path first. The collect() path can be refactored afterwards.

Copy link
Member

@lalitb lalitb May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can implement From trait, and use it throughout? And also, no need of cloning as we are already draining.

@@ -97,7 +97,7 @@ impl<T: fmt::Debug + Send + Sync + 'static> Aggregation for Sum<T> {
pub struct DataPoint<T> {
/// Attributes is the set of key value pairs that uniquely identify the
/// time series.
pub attributes: AttributeSet,
pub attributes: Vec<KeyValue>,
Copy link
Contributor

@utpilla utpilla May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a boxed slice instead of a Vec? It would save 8 bytes (usize length) per instance since unlike Vec we wouldn't need an additional pointer to track the capacity. That could save a considerable amount of memory if we are going to have a lot of these DataPoints.

Suggested change
pub attributes: Vec<KeyValue>,
pub attributes: Box<[KeyValue]>,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the PR desc, will revisit the public APIs. This PR is to unblock the unwanted exposure of AttributeSet outside of core sdk.

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit comment. Also, Collect cycle would need to be revisited if we need to clone to convert from AttributeSet. Better to add a TODO there?

Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason of disabling the Prometheus exporter? I'd rather not have component that cannot compile in the repo. Happy to help fix any compiling issues

@cijothomas
Copy link
Member Author

What's the reason of disabling the Prometheus exporter? I'd rather not have component that cannot compile in the repo. Happy to help fix any compiling issues

What other option we have ?

From desc:

Also removed opentelemetry-prometheus from CI for now, as it is not planned for the upcoming release : #1719

@cijothomas cijothomas merged commit 66b00d6 into open-telemetry:main May 21, 2024
21 of 22 checks passed
@cijothomas cijothomas deleted the cijothomas/attributeset-1 branch May 21, 2024 01:06
@cijothomas
Copy link
Member Author

Will follow up offline on how best to handle Prometheus part with @TommyCpp

@TommyCpp
Copy link
Contributor

What's the reason of disabling the Prometheus exporter? I'd rather not have component that cannot compile in the repo. Happy to help fix any compiling issues

What other option we have ?

From desc:

Also removed opentelemetry-prometheus from CI for now, as it is not planned for the upcoming release : #1719

IMO there is a difference between keeping it experimental(which means there will be breaking changes and bugs) and drops support completely. By removing it from CI it seems we are dropping support completely. By which point maybe it's better to move it to contrib repo

@cijothomas
Copy link
Member Author

We absolutely need it in main repo, as it is a spec-ed out component. (though experimental).
I can remove the code from repo completely and bring it back post 1.0, or keep it as-is, and remove from CI, re-enable CI post 1.0.

Happy to discuss other ideas! Maybe good topic for the community meeting tommorow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants