Skip to content

fix(sdk): wire meterProvider for span self-observability metrics and add otel.sdk.span.ended#1990

Merged
bobstrecansky merged 6 commits into
open-telemetry:mainfrom
intuibase:fix/sdk-self-observability-span-metrics
Jul 1, 2026
Merged

fix(sdk): wire meterProvider for span self-observability metrics and add otel.sdk.span.ended#1990
bobstrecansky merged 6 commits into
open-telemetry:mainfrom
intuibase:fix/sdk-self-observability-span-metrics

Conversation

@intuibase

Copy link
Copy Markdown
Contributor

SdkAutoloader was not passing the meterProvider to TracerProviderBuilder, so TracerSharedState always received null and never created the otel.sdk.span.started / otel.sdk.span.live counters even when OTEL_PHP_INTERNAL_METRICS_ENABLED=true.

TracerProviderFactory (used directly in examples) had the same gap — it was not forwarding a meterProvider to either SpanProcessorFactory or TracerProvider.

Also implements otel.sdk.span.ended (defined in SemConv but previously unrecorded): counter is created in TracerSharedState alongside spanStartedCounter and incremented in Span::end() with the otel.span.sampling_result attribute.

…add otel.sdk.span.ended

SdkAutoloader was not passing the meterProvider to TracerProviderBuilder,
so TracerSharedState always received null and never created the
otel.sdk.span.started / otel.sdk.span.live counters even when
OTEL_PHP_INTERNAL_METRICS_ENABLED=true.

TracerProviderFactory (used directly in examples) had the same gap —
it was not forwarding a meterProvider to either SpanProcessorFactory
or TracerProvider.

Also implements otel.sdk.span.ended (defined in SemConv but previously
unrecorded): counter is created in TracerSharedState alongside
spanStartedCounter and incremented in Span::end() with the
otel.span.sampling_result attribute.
@intuibase
intuibase requested a review from a team as a code owner June 25, 2026 15:56
@welcome

welcome Bot commented Jun 25, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.00%. Comparing base (6cb4156) to head (d227a9d).

Files with missing lines Patch % Lines
src/SDK/Logs/LoggerSharedState.php 0.00% 1 Missing ⚠️
src/SDK/SdkAutoloader.php 80.00% 1 Missing ⚠️
src/SDK/Trace/TracerSharedState.php 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1990      +/-   ##
============================================
- Coverage     68.02%   68.00%   -0.03%     
- Complexity     3075     3076       +1     
============================================
  Files           459      459              
  Lines          9017     9020       +3     
============================================
  Hits           6134     6134              
- Misses         2883     2886       +3     
Flag Coverage Δ
8.1 67.72% <76.92%> (-0.01%) ⬇️
8.2 67.90% <76.92%> (-0.01%) ⬇️
8.3 67.93% <76.92%> (+0.01%) ⬆️
8.4 67.91% <76.92%> (-0.07%) ⬇️
8.5 67.91% <76.92%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
src/SDK/Logs/Processor/BatchLogRecordProcessor.php 100.00% <100.00%> (ø)
src/SDK/Metrics/MetricReader/ExportingReader.php 99.04% <100.00%> (ø)
src/SDK/Trace/SpanProcessor/BatchSpanProcessor.php 100.00% <100.00%> (ø)
src/SDK/Trace/TracerProviderFactory.php 100.00% <100.00%> (ø)
src/SDK/Logs/LoggerSharedState.php 65.38% <0.00%> (ø)
src/SDK/SdkAutoloader.php 92.10% <80.00%> (-0.57%) ⬇️
src/SDK/Trace/TracerSharedState.php 63.88% <0.00%> (ø)

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

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

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

Comment thread src/SDK/Trace/TracerSharedState.php Outdated
Comment thread src/SDK/Trace/TracerSharedState.php Outdated
…eters

- Drop otel.sdk.span.ended (deprecated since spec 1.36.0; derive from
  otel.sdk.span.started - otel.sdk.span.live instead)
- Pass schemaUrl to getMeter() in all 5 SDK self-observability sites
  (TracerSharedState, Span processors, ExportingReader, LoggerSharedState)
@intuibase
intuibase requested a review from Nevay June 26, 2026 11:47
Comment thread src/SDK/Logs/Processor/BatchLogRecordProcessor.php Outdated
@intuibase
intuibase requested a review from Nevay June 26, 2026 20:09
Comment thread src/SDK/Logs/Processor/BatchLogRecordProcessor.php
@bobstrecansky
bobstrecansky merged commit 8b47ff2 into open-telemetry:main Jul 1, 2026
11 of 12 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.

4 participants