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

Add PoC implementation of Sum aggregator #2973

Closed
wants to merge 25 commits into from

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Jun 22, 2022

Based on #2954

Resolves #2972

@MrAlias MrAlias added pkg:SDK Related to an SDK package area:metrics Part of OpenTelemetry Metrics labels Jun 22, 2022
@MrAlias MrAlias added this to the Metric SDK: Alpha milestone Jun 22, 2022
@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #2973 (704b166) into new_sdk/main (8ac0588) will increase coverage by 0.4%.
The diff coverage is 77.5%.

❗ Current head 704b166 differs from pull request most recent head c7f9013. Consider uploading reports for the commit c7f9013 to get more accurate results

Impacted file tree graph

@@              Coverage Diff               @@
##           new_sdk/main   #2973     +/-   ##
==============================================
+ Coverage          74.0%   74.5%   +0.4%     
==============================================
  Files               114     125     +11     
  Lines              7930    8419    +489     
==============================================
+ Hits               5874    6278    +404     
- Misses             1921    2002     +81     
- Partials            135     139      +4     
Impacted Files Coverage Δ
attribute/value.go 88.9% <ø> (ø)
baggage/baggage.go 97.3% <ø> (ø)
bridge/opentracing/bridge.go 44.1% <0.0%> (ø)
bridge/opentracing/util.go 100.0% <ø> (ø)
bridge/opentracing/wrapper.go 100.0% <ø> (ø)
exporters/jaeger/uploader.go 48.2% <0.0%> (-0.4%) ⬇️
exporters/stdout/stdouttrace/config.go 100.0% <ø> (ø)
handler.go 100.0% <ø> (ø)
internal/matchers/expectation.go 0.0% <0.0%> (ø)
metric/instrument/config.go 0.0% <0.0%> (ø)
... and 44 more

Comment on lines 28 to 34
type sumAgg[N int64 | float64] struct {
// zero value used for the base of all new sums.
newFunc NewAtomicFunc[N]

// map[attribute.Set]Atomic[N]
current sync.Map
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are going to have better results if we just use a single lock over two atomic operations (both a load from the map, and a load from the register). I will put together a branch that would show this off.

Suggested change
type sumAgg[N int64 | float64] struct {
// zero value used for the base of all new sums.
newFunc NewAtomicFunc[N]
// map[attribute.Set]Atomic[N]
current sync.Map
}
type sumAgg[N int64 | float64] struct {
mu sync.Mutex
values map[*attribute.Set]N
}

Copy link
Contributor

Choose a reason for hiding this comment

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

@MrAlias
Copy link
Contributor Author

MrAlias commented Jul 7, 2022

Will recreate based on the merged form of #2954

@MrAlias MrAlias closed this Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics pkg:SDK Related to an SDK package
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants