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 support for multi-instrument callbacks #1202

Merged
merged 5 commits into from
Jan 10, 2024

Conversation

Nevay
Copy link
Contributor

@Nevay Nevay commented Dec 31, 2023

Adds a MeterInterface::batchObserve() method; internal preparations were done in #979.

Example usage, based on https://opentelemetry.io/docs/specs/otel/metrics/api/#multiple-instrument-callbacks:

$callback = $meter->batchObserve(
    function(ObserverInterface $usageObserver, ObserverInterface $pressureObserver): void {
        [$usage, $pressure] = expensive_system_call();
        $usageObserver->observe($usage);
        $pressureObserver->observe($pressure);
    },
    $meter->createObservableCounter('usage', description: 'count of items used'),
    $meter->createObservableGauge('pressure', description: 'force per unit area'),
);

@Nevay Nevay requested a review from a team December 31, 2023 11:51
Copy link

codecov bot commented Dec 31, 2023

Codecov Report

Attention: 63 lines in your changes are missing coverage. Please review.

Comparison is base (a196c13) 84.08% compared to head (990c15c) 83.28%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1202      +/-   ##
============================================
- Coverage     84.08%   83.28%   -0.81%     
- Complexity     2237     2248      +11     
============================================
  Files           285      285              
  Lines          6359     6401      +42     
============================================
- Hits           5347     5331      -16     
- Misses         1012     1070      +58     
Flag Coverage Δ
7.4 81.96% <32.25%> (-0.80%) ⬇️
8.0 83.22% <32.25%> (-0.79%) ⬇️
8.1 83.36% <32.25%> (-0.79%) ⬇️
8.2 83.36% <32.25%> (-0.79%) ⬇️
8.3 83.36% <32.25%> (-0.79%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/SDK/Metrics/MeterProvider.php 87.75% <100.00%> (+0.52%) ⬆️
src/SDK/Metrics/ObservableCallback.php 96.00% <100.00%> (+0.76%) ⬆️
src/SDK/Metrics/MetricRegistry/MetricRegistry.php 77.90% <0.00%> (ø)
src/API/Metrics/Noop/NoopMeter.php 0.00% <0.00%> (ø)
src/SDK/Metrics/ObservableInstrumentTrait.php 88.88% <77.77%> (-11.12%) ⬇️
src/SDK/Metrics/SynchronousInstrumentTrait.php 83.33% <83.33%> (ø)
src/SDK/Metrics/ObservableCallbackDestructor.php 0.00% <0.00%> (ø)
...Metrics/StalenessHandler/MultiReferenceCounter.php 0.00% <0.00%> (ø)
src/SDK/Metrics/AsynchronousInstruments.php 0.00% <0.00%> (ø)
src/SDK/Metrics/Meter.php 76.58% <17.07%> (-15.42%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a196c13...990c15c. Read the comment docs.

Not required, SDK will continue to work with lower API versions, only `::batchObserve()` won't be usable.
@Nevay Nevay force-pushed the feature/batch-observe branch from 5afd2bc to 990c15c Compare January 1, 2024 10:53
@bobstrecansky bobstrecansky merged commit 596d4a2 into open-telemetry:main Jan 10, 2024
11 of 13 checks passed
@Nevay Nevay deleted the feature/batch-observe branch January 10, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants