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

Replace internal aggregate Aggregator with Measure/ComputeAggregation and a Builder #4304

Merged
merged 15 commits into from
Jul 17, 2023

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Jul 10, 2023

The Aggregator interface is returned from the aggregate package for all aggregate functions. The methods of this returned interface are never used by the SDK at the same place, and in some places it is deliberately split apart to avoid the generic parameter.

Instead of having this mismatch, just have the aggregate function return input and output functions to satisfy the SDKs needs.

Additionally, as this change would require a considerable update to the aggregator constructors, replace these constructors with a Builder introduced in #4220

Part of #4220

@MrAlias MrAlias added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jul 10, 2023
@MrAlias MrAlias marked this pull request as ready for review July 10, 2023 20:18
@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #4304 (8826a13) into main (fdbcb9a) will increase coverage by 0.0%.
The diff coverage is 97.2%.

❗ Current head 8826a13 differs from pull request most recent head dbae8f9. Consider uploading reports for the commit dbae8f9 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #4304   +/-   ##
=====================================
  Coverage   83.6%   83.7%           
=====================================
  Files        183     184    +1     
  Lines      14227   14269   +42     
=====================================
+ Hits       11903   11948   +45     
+ Misses      2098    2095    -3     
  Partials     226     226           
Impacted Files Coverage Δ
sdk/metric/pipeline.go 92.7% <92.3%> (+1.2%) ⬆️
sdk/metric/instrument.go 91.7% <100.0%> (ø)
sdk/metric/internal/aggregate/aggregate.go 100.0% <100.0%> (ø)
sdk/metric/internal/aggregate/filter.go 100.0% <100.0%> (ø)
sdk/metric/internal/aggregate/histogram.go 100.0% <100.0%> (ø)
sdk/metric/internal/aggregate/lastvalue.go 100.0% <100.0%> (ø)
sdk/metric/internal/aggregate/sum.go 100.0% <100.0%> (ø)
sdk/metric/meter.go 85.9% <100.0%> (ø)

... and 1 file with indirect coverage changes

sdk/metric/internal/aggregate/aggregate.go Show resolved Hide resolved
sdk/metric/internal/aggregate/aggregate.go Outdated Show resolved Hide resolved
sdk/metric/instrument.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

I think the split between the interfaces is good, but I found the input/output naming confusing when reading the code that uses it, as I needed to remind myself what the input and output of the aggregate package is. Aggregate takes in measurements as inputs, and outputs an aggregation. Maybe something like InputMeasurement, and OutputAggregation would make more sense?

In particular, seeing out as a variable name on structs is much less clear than aggregator is to me.

sdk/metric/internal/aggregate/aggregate.go Outdated Show resolved Hide resolved
sdk/metric/pipeline.go Outdated Show resolved Hide resolved
@MrAlias
Copy link
Contributor Author

MrAlias commented Jul 14, 2023

I think the split between the interfaces is good, but I found the input/output naming confusing when reading the code that uses it, as I needed to remind myself what the input and output of the aggregate package is. Aggregate takes in measurements as inputs, and outputs an aggregation. Maybe something like InputMeasurement, and OutputAggregation would make more sense?

In particular, seeing out as a variable name on structs is much less clear than aggregator is to me.

@dashpole what do you think about Input -> Measure and Ouput -> Collect?

@dashpole
Copy link
Contributor

what do you think about Input -> Measure and Ouput -> Collect?

Measure() works for me. "Collect" is better, and I'm ok with that. I do feel like the function is doing more than just collecting. Something like "Combine" seems more accurate.

@MrAlias
Copy link
Contributor Author

MrAlias commented Jul 14, 2023

Would Compute or ComputeAggregation work @dashpole?

I'm a little skeptical about aggregate.ComputeAggregation, but not entirely opposed.

Combine also sounds reasonable to me if you think that better.

@dashpole
Copy link
Contributor

Ha, I like ComputeAggregation most of those :)

@MrAlias MrAlias changed the title Replace internal aggregate Aggregator with Input/Output and a Builder Replace internal aggregate Aggregator with Measure/ComputeAggregation and a Builder Jul 14, 2023
@MrAlias
Copy link
Contributor Author

MrAlias commented Jul 14, 2023

@dashpole / @pellared updated, PTAL

Copy link
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

The names are better 👍

@pellared pellared merged commit d18f201 into open-telemetry:main Jul 17, 2023
19 checks passed
@MrAlias MrAlias deleted the agg-builder branch July 17, 2023 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants