Skip to content

feat: add opentelemetry/opentelemetry-metrics-runtime to the distro#131

Merged
intuibase merged 1 commit into
open-telemetry:mainfrom
intuibase:feat/runtime-metrics
Jul 14, 2026
Merged

feat: add opentelemetry/opentelemetry-metrics-runtime to the distro#131
intuibase merged 1 commit into
open-telemetry:mainfrom
intuibase:feat/runtime-metrics

Conversation

@intuibase

Copy link
Copy Markdown
Contributor

Adds open-telemetry/opentelemetry-metrics-runtime 0.1.0 as a production dependency so the distro automatically exports PHP runtime metrics (memory, GC, etc.) via the native async OTLP transport.

Supporting changes required to make eager SDK initialization safe:

  • PhpPartFacade::earlySetup() now also registers the distro's resource- attribute override and SPI detector, not only the native OTLP serializer and transport factory. $nativePartVersion is stored before registerAutoloaderForVendorDir() runs so earlySetup() can read it when triggered by a Composer files-autoload entry.

  • New tools/build/fix_composer_autoload_order.php applies two ordering fixes to any vendor directory (scoped and not_scoped alike):

    1. Prepends earlySetup.php as the very first files-autoload entry so the distro's overrides win the race against eager instrumentation init.
    2. Reorders exporter-otlp/_register.php before sdk/_autoload.php so that OTLP exporter factories are registered when the SDK auto-initializer runs during eager init (fixes "Span exporter factory not defined for: otlp" on non-scoped builds). The two ordering fixes previously embedded in fix_scoped_composer_autoload.php (scoped-only) are removed from there; that script now only handles the three scoping-specific fixes (ClassLoader rewrite, PSR-4/classmap rewrite, hash rehashing).
  • MockOTelCollector now accepts /v1/metrics and /v1/logs with HTTP 202 so the collector mock does not crash when metrics-runtime triggers a metrics flush on request shutdown.

  • generate_composer_lock_files.sh excludes opentelemetry-metrics-runtime from the test lock-file variant (consistent with opentelemetry-auto-*).

Adds open-telemetry/opentelemetry-metrics-runtime 0.1.0 as a production
dependency so the distro automatically exports PHP runtime metrics (memory,
GC, etc.) via the native async OTLP transport.

Supporting changes required to make eager SDK initialization safe:

- PhpPartFacade::earlySetup() now also registers the distro's resource-
  attribute override and SPI detector, not only the native OTLP serializer
  and transport factory. $nativePartVersion is stored before
  registerAutoloaderForVendorDir() runs so earlySetup() can read it when
  triggered by a Composer files-autoload entry.

- New tools/build/fix_composer_autoload_order.php applies two ordering
  fixes to any vendor directory (scoped and not_scoped alike):
  1. Prepends earlySetup.php as the very first files-autoload entry so
     the distro's overrides win the race against eager instrumentation init.
  2. Reorders exporter-otlp/_register.php before sdk/_autoload.php so that
     OTLP exporter factories are registered when the SDK auto-initializer
     runs during eager init (fixes "Span exporter factory not defined for:
     otlp" on non-scoped builds).
  The two ordering fixes previously embedded in fix_scoped_composer_autoload.php
  (scoped-only) are removed from there; that script now only handles the three
  scoping-specific fixes (ClassLoader rewrite, PSR-4/classmap rewrite, hash
  rehashing).

- MockOTelCollector now accepts /v1/metrics and /v1/logs with HTTP 202 so
  the collector mock does not crash when metrics-runtime triggers a metrics
  flush on request shutdown.

- generate_composer_lock_files.sh excludes opentelemetry-metrics-runtime
  from the test lock-file variant (consistent with opentelemetry-auto-*).
@intuibase intuibase self-assigned this Jul 14, 2026
@intuibase
intuibase marked this pull request as ready for review July 14, 2026 11:09
@intuibase
intuibase requested a review from a team as a code owner July 14, 2026 11:09
@intuibase
intuibase requested a review from SergeyKleyman July 14, 2026 11:09
@intuibase intuibase linked an issue Jul 14, 2026 that may be closed by this pull request
6 tasks
Comment thread tests/OTelDistroTests/ComponentTests/Util/MockOTelCollector.php
@intuibase
intuibase merged commit ea800c0 into open-telemetry:main Jul 14, 2026
67 checks passed
@intuibase
intuibase deleted the feat/runtime-metrics branch July 14, 2026 12:50
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.

Implement SDK health metrics in OpenTelemetry PHP SDK

2 participants