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

handle empty meter observers #1490

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

brettmc
Copy link
Collaborator

@brettmc brettmc commented Jan 28, 2025

if no observers are registered for a meter's instruments, some tests were emitting php warnings:

  • foreach() argument must be of type array|object, null given
  • Undefined array key XXX

null coalesce to an empty array to make the test happy.

if no observers are registered for a meter's instruments, some tests were emitting php warnings:
- foreach() argument must be of type array|object, null given
- Undefined array key XXX
null coalesce to an empty array to make the test happy.
@brettmc brettmc requested a review from a team as a code owner January 28, 2025 04:41
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.84%. Comparing base (7eb3abb) to head (46856d6).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1490      +/-   ##
============================================
+ Coverage     70.71%   70.84%   +0.13%     
  Complexity     2761     2761              
============================================
  Files           408      408              
  Lines          8341     8341              
============================================
+ Hits           5898     5909      +11     
+ Misses         2443     2432      -11     
Flag Coverage Δ
8.1 70.45% <100.00%> (+0.01%) ⬆️
8.2 70.69% <100.00%> (+0.13%) ⬆️
8.3 70.65% <100.00%> (+<0.01%) ⬆️
8.4 70.79% <100.00%> (+0.21%) ⬆️
8.5 70.79% <100.00%> (+0.13%) ⬆️

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

Files with missing lines Coverage Δ
src/SDK/Metrics/Meter.php 69.60% <100.00%> (+2.79%) ⬆️

... and 7 files with indirect coverage changes


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 7eb3abb...46856d6. Read the comment docs.

@Nevay
Copy link
Contributor

Nevay commented Jan 28, 2025

Same fix needed for the foreach ($this->instruments->writers loop.

$mp = (new MeterProviderBuilder())
    ->addReader(new ExportingReader(new InMemoryExporter()))
    ->build();
$mp->getMeter('test')->createObservableCounter('c')->observe(static fn() => null);
$mp->updateConfigurator(Configurator::meter());

@brettmc brettmc merged commit 3e8ae81 into open-telemetry:main Jan 29, 2025
11 checks passed
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