GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Spatial aggregation for async instruments with filtering views by fandreuz · Pull Request #7264 · open-telemetry/opentelemetry-java

Conversation

@fandreuz

@fandreuz fandreuz commented Apr 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #4901

I propose the following changes:

  • AsynchronousMetricStorage now declares void record(Attributes, long) and void record(Attributes, double) instead of a single void record(Measurement), to enable using AggregatorHandle within the class.
  • AsynchronousMetricStorage now contains two long fields (startEpochNanos, epochNanos) which are injected before running the callbacks, as an alternative to passing a Measurement object.
  • Some tests had to change due to the change in the interface of AsynchronousMetricStorage

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
fandreuz added 4 commits April 9, 2025 00:55
@fandreuz
wip
6816f91
@fandreuz
fix tests
ed783f9
@fandreuz
keep ref value locally
0c63775
@fandreuz
comments
ab8bd4d
@fandreuz
fandreuz requested a review from a team as a code owner April 9, 2025 22:51
@linux-foundation-easycla

linux-foundation-easycla Bot commented Apr 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: fandreuz / name: Francesco Andreuzzi (944b3ef, ed783f9, 6816f91, 8bde0f4, ab8bd4d, 4254d30, 9dcaf3b, fa58b02, 0dca607, f831572, 561e479, 4fe5834, 0c63775, e942dc2, cbe0784, 63f2471, 4e566d7, 1609f5f, 1f9a4b5, 29f93c5, 4613e7c, 7115187, 6e96eda, a5d8b67, 1bc1d78, 1371683, 4b3f874, 53ad5dd, f6f1db7)
  • ✅ login: jack-berg (44b9825)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz

fandreuz commented Apr 9, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I'd like to discuss the test here. I would expect a cumulative sum instrument to aggregate all occurrences with empty attributes. Thus, I would expect to see 6 here instead of 3.

To preserve this behavior, I clear the values for all the attributes at every collection, which is why AsynchronousMetricStorageTest#collect_reusableData_reusedObjectsAreReturnedOnSecondCall is failing. I'd like to clarify this aspect before fixing it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jack-berg

jack-berg commented Apr 14, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I'd like to discuss the test here. I would expect a cumulative sum instrument to aggregate all occurrences with empty attributes. Thus, I would expect to see 6 here instead of 3.

Yes I believe you're correct. The test / logic seem appear to be incorrect currently

Oh I forgot about a fundamental detail of asynchronous instruments: conceptually, when you make an observation with a cumulative instrument, we say that you are observing a cumulative value. Thus, if we have a reader with cumulative temporality which reads twice and invokes the callbacks twice, and the callback records the same value 3 each time, the reported value should indeed be 3 and not 6.

Consider it from the perspective of this instrumentation which records information about classes loaded. If in sequential reads the callback records that 100 classes have been loaded, the output of a cumulative reader should always be 100, not N*100 (where N is the number of times the callback has been invoked). Instrumentation is not responsible for managing state and recording only the delta.

fandreuz reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jack-berg
jack-berg reviewed Apr 14, 2025
View reviewed changes

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for working on this. This is pretty complex code when you consider the combinations of cumulative + delta, reusable + immutable data mode, and our desire to maintain zero memory allocations with reusable data mode after the application reaches steady state.

So reviews need to be slow / careful, but I am definitely interested in getting this issue resolved!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz reacted with rocket emoji
All reactions
  • 🚀 1 reaction
Comment thread ...rics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/SdkObservableMeasurement.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorage.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorage.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...ics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorage.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread .../src/test/java/io/opentelemetry/sdk/metrics/internal/state/SdkObservableMeasurementTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz and others added 3 commits April 16, 2025 00:17
@fandreuz @jack-berg
review comment
e942dc2
Co-authored-by: jack-berg <[email protected]>
@fandreuz
remove log statement
fa58b02
@fandreuz
reusable currentPoints
561e479
@fandreuz
fandreuz force-pushed the 4901-aggregate-async-instruments branch from 00264c9 to 561e479 Compare April 16, 2025 23:11
@fandreuz
comments and fix test
8bde0f4
@fandreuz

fandreuz commented Apr 16, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I'd like to discuss the test here. I would expect a cumulative sum instrument to aggregate all occurrences with empty attributes. Thus, I would expect to see 6 here instead of 3.

Yes I believe you're correct. The test / logic seem appear to be incorrect currently

Oh I forgot about a fundamental detail of asynchronous instruments: conceptually, when you make an observation with a cumulative instrument, we say that you are observing a cumulative value. Thus, if we have a reader with cumulative temporality which reads twice and invokes the callbacks twice, and the callback records the same value 3 each time, the reported value should indeed be 3 and not 6.

Consider it from the perspective of this instrumentation which records information about classes loaded. If in sequential reads the callback records that 100 classes have been loaded, the output of a cumulative reader should always be 100, not N*100 (where N is the number of times the callback has been invoked). Instrumentation is not responsible for managing state and recording only the delta.

Thanks for the clarification, I fixed the test accordingly

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 3 commits April 16, 2025 23:27
@fandreuz
Merge branch 'main' into 4901-aggregate-async-instruments
4fe5834
@fandreuz
set epoch info once
6e96eda
@fandreuz
add test for setActiveReader
4b3f874
@fandreuz

fandreuz commented Apr 19, 2025

Copy link
Copy Markdown
Contributor Author

Hi @jack-berg, are the test failure something I should be concerned of? They don't seem to be related to the diff

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jack-berg

jack-berg commented Apr 21, 2025

Copy link
Copy Markdown
Member

Hi @jack-berg, are the test failure something I should be concerned of? They don't seem to be related to the diff

The "windows-latest, 21" failure is unrelated, but the "ubunut-latest, 21" failure is: https://github.com/open-telemetry/opentelemetry-java/actions/runs/14524924371/job/40754298012?pr=7264#step:6:6005

This test codifies performance improvements we made with "reusuable data mode", and acts as a barrier to make sure we don't regress. If you compare the output of the benchmark on main to the output on this branch for the DELTA, REUSABLE_DATA, ASYNC_COUNTER case, we see an increase in B/op from 35_592 to 28_016_028. Ouch!

fandreuz reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz added 10 commits April 23, 2025 00:48
@fandreuz
reduce allocation in REUSABLE_DATA mode
4254d30
@fandreuz
handle overflow
0dca607
@fandreuz
dont delete all of them
9dcaf3b
@fandreuz
gt
1609f5f
@fandreuz
ops
944b3ef
@fandreuz
reusable handles
7115187
@fandreuz
pool for handles
4e566d7
@fandreuz
new test
a5d8b67
@fandreuz
save some alloc
f831572
@fandreuz
process only when needed
1bc1d78
fandreuz added 2 commits April 24, 2025 00:54
@fandreuz
one less lambda
63f2471
@fandreuz
reduce allocs
29f93c5
@fandreuz
fandreuz force-pushed the 4901-aggregate-async-instruments branch from 3b3f85a to 29f93c5 Compare April 24, 2025 01:22
@fandreuz
no useless allocs
cbe0784
@codecov

codecov Bot commented Apr 24, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.90%. Comparing base (8c1e348) to head (44b9825).
Report is 10 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7264      +/-   ##
============================================
- Coverage     90.03%   89.90%   -0.14%     
+ Complexity     6916     6893      -23     
============================================
  Files           787      785       -2     
  Lines         20864    20791      -73     
  Branches       2023     2024       +1     
============================================
- Hits          18785    18692      -93     
- Misses         1441     1460      +19     
- Partials        638      639       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz
new test
4613e7c
@fandreuz

fandreuz commented Apr 24, 2025

Copy link
Copy Markdown
Contributor Author

Hi @jack-berg, all green finally!

I had to make some changes in DoubleLastValueAggregator because I started getting too many allocation there as well.

The root cause is apparently the boxing due to the usage of AtomicReference<Double> within DoubleLastValueAggregator:

image

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fandreuz
fix impl
1371683
fandreuz
fandreuz commented Apr 24, 2025
View reviewed changes
Comment thread ...rc/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregator.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

fandreuz and others added 4 commits April 25, 2025 00:48
@fandreuz
atomicreference+atomiclong
1f9a4b5
@fandreuz
trigger
53ad5dd
@fandreuz
Merge remote-tracking branch 'origin/main' into 4901-aggregate-async-…
f6f1db7
…instruments
@jack-berg
Delete unused Measurement and related code
44b9825
jack-berg
jack-berg approved these changes May 1, 2025
View reviewed changes

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Great work. Although you forgot one thing - you've eliminated the need for Measurement and all related code. I pushed a commit which deletes it and removes 345 lines! More functionality with less code!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fandreuz reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@jack-berg
jack-berg merged commit 7cbcdd6 into open-telemetry:main May 2, 2025
@iRevive iRevive mentioned this pull request Jun 14, 2025
Update opentelemetry-api, ... to 1.51.0 typelevel/otel4s#985
Merged
@jack-berg jack-berg mentioned this pull request Jan 27, 2026
Update LongLastValueAggregator algo to avoid allocations #8017
Merged
@trask trask mentioned this pull request Jul 13, 2026
Remove JMX registration requirement for Apache DBCP 2.0 metrics open-telemetry/opentelemetry-java-instrumentation#19160
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jack-berg jack-berg jack-berg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Async instruments don't do spatial reaggregation when attributes are dropped

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@fandreuz @jack-berg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.