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

[processor/deltatocumulative]: linear pipeline #34757

Closed
wants to merge 7 commits into from

Conversation

sh0rez
Copy link
Member

@sh0rez sh0rez commented Aug 20, 2024

Description:
Refactors the high-level pipeline to lower general complexity.

Before:

  • streams.Map based pipeline
  • all functionality (staleness, limits, accumulation) happens in overloaded Map.Store methods
  • Highly nested data structure -> hard to reason about
  • leans towards hard to spot bugs
    • e.g.: stream limit accidentally enforced per-datatype, instead of globally
  • weird error based metric telemetry

After:

  • functionality decoupled as far as possible
  • high-level, datatype agnostic ConsumeMetrics that ties together staleness, limits, accumulation, etc.
  • standard TelemetryBuilder powered metric recording

Link to tracking Issue: none

Testing: Existing tests were adapted to new architecture

Documentation: not needed

@sh0rez
Copy link
Member Author

sh0rez commented Aug 20, 2024

no changelog needed imo

Transforms the processors main logic from a deeply-nested, map structure
that overloads the Store operation to a strongly decoupled, linear
processing flow that nearly entirely happens within `ConsumeMetrics`,
greatly improving understandability of the code
moves most tests from `internal/delta` to the processor itself,
excercising the public api.
hides types from public api that don't need to be public
adds summary datatype to make type switch exhaustive
@sh0rez sh0rez marked this pull request as ready for review August 23, 2024 09:19
@sh0rez sh0rez requested a review from a team August 23, 2024 09:19
@ArthurSens
Copy link
Member

Hey @sh0rez, I'd love to help you out here but I'm new to the codebase and 2k line changes might be a bit too much for my first review 😅

Do you think you could break this PR into smaller ones?

Or maybe you could tell me the biggest problems of the current codebase, I could try to come up with the refactoring myself and you review?


The options above are just to unblock you, if you think you can progress without my help please do so :)

@sh0rez
Copy link
Member Author

sh0rez commented Sep 6, 2024

Closing in favor of #35048

@sh0rez sh0rez closed this Sep 6, 2024
jpkrohling pushed a commit that referenced this pull request Sep 27, 2024
**Description:** 
Partially introduces a highly decoupled, linear processing pipeline.
Implemented as a standalone struct to make review easier, will refactor
this later.
Instead of overloading `Map.Store()` to do aggregation, staleness and
limiting, this functionality is now explcitly handled in
`ConsumeMetrics`.

This highly aids readability and makes understanding this processor a
lot easier, as less mental context needs to be kept.

*Notes to reviewer*:
See
[`68dc901`](68dc901)
for the main added logic.
Compare `processor.go` (old, nested) to `linear.go` (new, linear)

Replaces #34757 

**Link to tracking Issue:** none

**Testing:** This is a refactor. Existing tests were not modified and
still pass

**Documentation:** not needed
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this pull request Oct 4, 2024
…#35048)

**Description:** 
Partially introduces a highly decoupled, linear processing pipeline.
Implemented as a standalone struct to make review easier, will refactor
this later.
Instead of overloading `Map.Store()` to do aggregation, staleness and
limiting, this functionality is now explcitly handled in
`ConsumeMetrics`.

This highly aids readability and makes understanding this processor a
lot easier, as less mental context needs to be kept.

*Notes to reviewer*:
See
[`68dc901`](open-telemetry@68dc901)
for the main added logic.
Compare `processor.go` (old, nested) to `linear.go` (new, linear)

Replaces open-telemetry#34757 

**Link to tracking Issue:** none

**Testing:** This is a refactor. Existing tests were not modified and
still pass

**Documentation:** not needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants