Skip to content

metricstarttimeprocessor: Implementation of the subtractinitial strategy #38594

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

Merged

Conversation

ridwanmsharif
Copy link
Member

@ridwanmsharif ridwanmsharif commented Mar 13, 2025

Description

Addresses #38379.

Some of this logic already existed in the GCM exporter.

For each resource, and for each timeseries

  • Skip if the point is not a cumulative sum, histogram, exp histogram, or summary.
  • Lookup the timeseries in the cache. If it is not present, drop this point from the batch, and store the timestamp and value (including bucket counts, etc) in the cache.
  • Subtract cumulative values (e.g. sum, bucket counts) of the cached timeseries from the current timeseries, and set the start timestamp to the cached point's timestamp.

Link to tracking issue

Fixes #38379.

Testing

Added unit and integration tests.

Documentation

Readme already covers this strategy

@ridwanmsharif
Copy link
Member Author

This builds on top of #38583, which in turn builds on top of #38579. The PRs should be merged in reverse order.

@ridwanmsharif ridwanmsharif force-pushed the ridwanmsharif/subtract-strategy-v2 branch 4 times, most recently from 6f1f6f0 to 7c597ac Compare March 19, 2025 02:05
@ridwanmsharif ridwanmsharif marked this pull request as ready for review March 19, 2025 02:05
@ridwanmsharif ridwanmsharif requested a review from a team as a code owner March 19, 2025 02:05
@ridwanmsharif ridwanmsharif force-pushed the ridwanmsharif/subtract-strategy-v2 branch 3 times, most recently from 5c61b16 to 51576dd Compare March 19, 2025 04:12
@ridwanmsharif
Copy link
Member Author

Note to the reviewers:

  • processor/metricstarttimeprocessor/internal/subtractinitial/adjuster.go contains all the logic of the new adjuster
  • processor/metricstarttimeprocessor/internal/subtractinitial/adjuster_test.go

The other changes were made so there is deduplication of the test runners (pulled out to a common testhelper internal module)

@ridwanmsharif ridwanmsharif force-pushed the ridwanmsharif/subtract-strategy-v2 branch from 51576dd to 740b90a Compare March 19, 2025 05:39
@ridwanmsharif
Copy link
Member Author

cc @aabmass for context with the GCM exporter normalization this mimics

@aabmass
Copy link
Member

aabmass commented Mar 19, 2025

fyi @pintohutch

@atoulme
Copy link
Contributor

atoulme commented Mar 19, 2025

Given that the author is codeowner, who should review this change? What type of review would you like? Please indicate this so we can best help.

@ridwanmsharif
Copy link
Member Author

ridwanmsharif commented Mar 19, 2025

Given that the author is codeowner, who should review this change? What type of review would you like? Please indicate this so we can best help.

@dashpole (the proposer and other codeowner) would be the ideal candidate, but in his stead, the owners of the googlecloud exporter that this change mimics, would suffice for a thorough review of the adjustment logic. Either of @pintohutch, @aabmass or @psx95 would be okay for this.

Will also need someone from open-telemetry/collector-contrib-approvers to then review to sanity check and merge once ready

@pintohutch
Copy link
Contributor

Also @bwplotka FYI

Copy link
Contributor

@pintohutch pintohutch left a comment

Choose a reason for hiding this comment

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

Mostly questions - thanks for doing this!

Copy link
Contributor

github-actions bot commented Apr 8, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 8, 2025
@ridwanmsharif ridwanmsharif force-pushed the ridwanmsharif/subtract-strategy-v2 branch from 0b562f5 to 7dd5402 Compare May 2, 2025 13:57
@ridwanmsharif ridwanmsharif marked this pull request as ready for review May 2, 2025 13:58
@ridwanmsharif ridwanmsharif force-pushed the ridwanmsharif/subtract-strategy-v2 branch 4 times, most recently from 3004e15 to 736b2d3 Compare May 2, 2025 18:28
Copy link
Contributor

@braydonk braydonk left a comment

Choose a reason for hiding this comment

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

Mostly naming nits, functionality LGTM

@ridwanmsharif ridwanmsharif force-pushed the ridwanmsharif/subtract-strategy-v2 branch from 736b2d3 to 98f5481 Compare May 5, 2025 03:53
@ridwanmsharif ridwanmsharif requested a review from braydonk May 5, 2025 03:53
@ridwanmsharif
Copy link
Member Author

Also I'm curious why this strategy is called substractinitial not actually true reset given the definition of the latter matches this PR algo https://opentelemetry.io/docs/specs/otel/metrics/data-model/#cumulative-streams-inserting-true-reset-points 🙈 The current true reset strategy for metricstarttime is objectively broken.

Especially given this is a new process, why we cannot actually "fix" true reset and deprecate the adjuster in prometheusreceiver? Are we not confusing users with the current proposal?

Naming is hard 🙈

I think the existing strategy is also a valid one. Described in more detail here: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstarttimeprocessor#strategy-true-reset-point
And its the default strategy used by the prometheus receiver (which this processor replaces).

Opting to keep things as is here to keep the PR ready but open to deprecating other strategies or simplifying this moving forward, should only this strategy be useful

@braydonk braydonk added ready to merge Code review completed; ready to merge by maintainers and removed waiting-for-code-owners labels May 5, 2025
@braydonk
Copy link
Contributor

braydonk commented May 5, 2025

I think this is ready to merge since the other codeowner, dashpole, is on leave meaning it's just Ridwan. Bartek's most recent comments don't seem to be PR blocking based on my reading. A maintainer may remove this label if they think it's not ready to merge for whatever reason.

@atoulme
Copy link
Contributor

atoulme commented May 5, 2025

I have reviewed the code summarily and it passes my review. Codeowners have reviewed and approved the change.

@atoulme atoulme merged commit d23e351 into open-telemetry:main May 5, 2025
189 of 190 checks passed
@github-actions github-actions bot added this to the next release milestone May 5, 2025
@ridwanmsharif ridwanmsharif deleted the ridwanmsharif/subtract-strategy-v2 branch May 5, 2025 17:59
@mx-psi mx-psi mentioned this pull request May 6, 2025
mx-psi added a commit that referenced this pull request May 6, 2025
- **[receiver/prometheus] Upgrade
receiver.prometheus.removeLegacyResourceAttributes feature flag
(#39803)**
- **Feature/update library versions (#39848)**
- **metricstarttimeprocessor: Implementation of the subtractinitial
strategy (#38594)**
- **[mongodbatlasreceiver] Add baseURL config (#39345)**
- **[receiver/splunkenterprise] Unexport InfoEntry and InfoContent
(#39830)**
- **[pkg/ottl] Add support for HasPrefix and HasSuffix (#39825)**
- **[receiver/snowflakereceiver] fix(security): CVE-2025-46327 :
Upgraded gosnowflake to v1.13.3 (#39862)**
- **[pkg/winperfcounters] Add support to retrieve raw values (#39835)**
- **Update All github.com/aws packages (#39867)**
- **use a single version**

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Ridwan Sharif <[email protected]>
Signed-off-by: Bogdan Drutu <[email protected]>
Co-authored-by: Curtis Robert <[email protected]>
Co-authored-by: Ramachandran A G <[email protected]>
Co-authored-by: Antoine Toulme <[email protected]>
Co-authored-by: Ridwan Sharif <[email protected]>
Co-authored-by: Artur Santos <[email protected]>
Co-authored-by: Christos Markou <[email protected]>
Co-authored-by: Edmo Vamerlatti Costa <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bogdan Drutu <[email protected]>
Co-authored-by: Paulo Janotti <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: opentelemetrybot <[email protected]>
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 6, 2025
…egy (open-telemetry#38594)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Addresses open-telemetry#38379.

Some of this logic already existed in the [GCM
exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/main/exporter/collector/internal/normalization/standard_normalizer.go).

For each resource, and for each timeseries
- Skip if the point is not a cumulative sum, histogram, exp histogram,
or summary.
- Lookup the timeseries in the cache. If it is not present, drop this
point from the batch, and store the timestamp and value (including
bucket counts, etc) in the cache.
- Subtract cumulative values (e.g. sum, bucket counts) of the cached
timeseries from the current timeseries, and set the start timestamp to
the cached point's timestamp.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#38379.

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added unit and integration tests.

<!--Describe the documentation added.-->
#### Documentation
Readme already covers this strategy

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Ridwan Sharif <[email protected]>
vincentfree pushed a commit to ing-bank/opentelemetry-collector-contrib that referenced this pull request May 20, 2025
…egy (open-telemetry#38594)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Addresses open-telemetry#38379.

Some of this logic already existed in the [GCM
exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/main/exporter/collector/internal/normalization/standard_normalizer.go).

For each resource, and for each timeseries
- Skip if the point is not a cumulative sum, histogram, exp histogram,
or summary.
- Lookup the timeseries in the cache. If it is not present, drop this
point from the batch, and store the timestamp and value (including
bucket counts, etc) in the cache.
- Subtract cumulative values (e.g. sum, bucket counts) of the cached
timeseries from the current timeseries, and set the start timestamp to
the cached point's timestamp.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#38379.

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added unit and integration tests.

<!--Describe the documentation added.-->
#### Documentation
Readme already covers this strategy

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Ridwan Sharif <[email protected]>
dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…egy (open-telemetry#38594)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Addresses open-telemetry#38379.

Some of this logic already existed in the [GCM
exporter](https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/main/exporter/collector/internal/normalization/standard_normalizer.go).

For each resource, and for each timeseries
- Skip if the point is not a cumulative sum, histogram, exp histogram,
or summary.
- Lookup the timeseries in the cache. If it is not present, drop this
point from the batch, and store the timestamp and value (including
bucket counts, etc) in the cache.
- Subtract cumulative values (e.g. sum, bucket counts) of the cached
timeseries from the current timeseries, and set the start timestamp to
the cached point's timestamp.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#38379.

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added unit and integration tests.

<!--Describe the documentation added.-->
#### Documentation
Readme already covers this strategy

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Ridwan Sharif <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/metricstarttime ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[metricstarttimeprocessor] Add subtract_initial_point strategy
9 participants