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 enabled functions #1350

Merged
merged 5 commits into from
Jul 19, 2024
Merged

Conversation

brettmc
Copy link
Collaborator

@brettmc brettmc commented Jul 18, 2024

spec 1.34 requires logger, tracer, and instrument to have an enabled function. It doesn't do anything helpful yet, but #1349 should resolve this.

Closes: #1324
Closes: #1325
Closes: #1326

spec 1.34 requires logger, tracer, and instrument to have an enabled function
@brettmc brettmc requested a review from a team July 18, 2024 07:07
Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 46.15385% with 14 lines in your changes missing coverage. Please review.

Project coverage is 74.56%. Comparing base (17ad56a) to head (eb41aea).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1350      +/-   ##
============================================
- Coverage     74.61%   74.56%   -0.05%     
- Complexity     2504     2517      +13     
============================================
  Files           355      355              
  Lines          7180     7206      +26     
============================================
+ Hits           5357     5373      +16     
- Misses         1823     1833      +10     
Flag Coverage Δ
8.1 74.25% <46.15%> (-0.06%) ⬇️
8.2 74.49% <46.15%> (-0.02%) ⬇️
8.3 74.50% <46.15%> (-0.02%) ⬇️
8.4 74.47% <46.15%> (-0.02%) ⬇️

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

Files Coverage Δ
src/API/Logs/NoopLogger.php 100.00% <100.00%> (ø)
src/API/Trace/NoopTracer.php 100.00% <100.00%> (+100.00%) ⬆️
src/SDK/Logs/Logger.php 100.00% <100.00%> (ø)
...rc/SDK/Metrics/DefaultAggregationProviderTrait.php 100.00% <ø> (ø)
src/SDK/Metrics/ObservableInstrumentTrait.php 90.00% <100.00%> (+1.11%) ⬆️
src/SDK/Metrics/SynchronousInstrumentTrait.php 85.71% <100.00%> (+2.38%) ⬆️
src/SDK/Trace/Tracer.php 100.00% <100.00%> (ø)
src/API/Metrics/Noop/NoopCounter.php 0.00% <0.00%> (ø)
src/API/Metrics/Noop/NoopHistogram.php 0.00% <0.00%> (ø)
src/API/Metrics/Noop/NoopObservableCounter.php 0.00% <0.00%> (ø)
... and 4 more

... and 4 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 17ad56a...eb41aea. Read the comment docs.


public function enabled(): bool
{
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

https://opentelemetry.io/docs/specs/otel/metrics/sdk/#instrument-enabled

The instrument Enabled operation MUST return false if [...] All resolved views for the instrument are configured with the Drop Aggregation.

Can be implemented by adding a MetricWriterInterface::enabled(Instrument) method:

  • in MetricRegistry return isset($this->instrumentToStreams[spl_object_id($instrument)]);
  • in SynchronousInstrumentTrait and ObservableInstrumentTrait return $this->writer->enabled($this->instrument);

src/API/Metrics/Instrument.php Outdated Show resolved Hide resolved
@bobstrecansky bobstrecansky merged commit 4ed0d87 into open-telemetry:main Jul 19, 2024
9 of 10 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
3 participants