Skip to content

NH-146966 PHP: explore and adopt declarative config - #219

Open
jerrytfleung wants to merge 37 commits into
mainfrom
declarative
Open

jerrytfleung wants to merge 37 commits into
mainfrom
declarative

Conversation

@jerrytfleung

@jerrytfleung jerrytfleung commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description of changes:

  • Added declarative configuration support for apm-php
  • Updated phpstan static check tool

Related issues

NH-146966

@jerrytfleung jerrytfleung changed the title Declarative NH-146966 PHP: explore and adopt declarative config Sep 17, 2026
@jerrytfleung
jerrytfleung marked this pull request as ready for review September 18, 2026 18:01
@jerrytfleung
jerrytfleung requested review from a team as code owners September 18, 2026 18:01
Copilot AI lite review requested due to automatic review settings September 18, 2026 18:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical nullable-settings regressions, a breaking K8s constructor signature, and malformed example attribute keys remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds declarative OpenTelemetry configuration support for PHP components and updates PHPStan tooling.

Changes:

  • Adds component providers for samplers, processors, detectors, and propagators.
  • Adds YAML/PHP configuration examples and validation.
  • Updates SDK initialization, defaults, compatibility, and PHPStan configuration.
File summaries
File Summary
tests/Unit/Trace/Sampler/SamplerTest.php Updated sampler tests.
tests/Unit/Resource/Detectors/K8sTest.php Updated Kubernetes detector tests.
src/Trace/SwoSamplerFactory.php Uses centralized defaults.
src/Trace/SpanProcessor/TransactionNameSpanProcessor.php Supports configured transaction names.
src/Trace/SpanProcessor/ResponseTimeSpanProcessor.php Updates metrics integration.
src/Trace/Sampler/Settings.php Merges sampler settings.
src/Trace/Sampler/OboeSampler.php Updates sampler settings handling.
src/Trace/Sampler/JsonSampler.php Uses centralized path defaults.
src/Trace/Sampler/HttpSampler.php Updates metrics integration.
src/SdkAutoloader.php Loads distribution configuration.
src/Resource/Detectors/K8s.php Adds declarative Kubernetes settings.
src/ComponentProvider/Validation/Validation.php Adds configuration validation.
src/ComponentProvider/Trace/SpanProcessorTransactionName.php Provides transaction-name configuration.
src/ComponentProvider/Trace/SpanProcessorResponseTime.php Provides response-time configuration.
src/ComponentProvider/Trace/SamplerSolarwindsJson.php Provides JSON sampler configuration.
src/ComponentProvider/Trace/SamplerSolarwindsHttp.php Provides HTTP sampler configuration.
src/ComponentProvider/ResponsePropagator/ResponsePropagatorXTraceOptionsResponse.php Registers X-Trace options response propagation.
src/ComponentProvider/ResponsePropagator/ResponsePropagatorXTrace.php Registers X-Trace response propagation.
src/ComponentProvider/Propagator/PropagatorXTraceOptions.php Registers X-Trace options propagation.
src/ComponentProvider/Propagator/PropagatorSwoTraceState.php Registers SWO trace-state propagation.
src/ComponentProvider/Detector/DetectorUams.php Registers the UAMS detector.
src/ComponentProvider/Detector/DetectorSwo.php Registers the SWO detector.
src/ComponentProvider/Detector/DetectorK8s.php Registers Kubernetes detector configuration.
src/Common/Configuration/KnownValues.php Centralizes configuration defaults.
src/_autoload.php Avoids duplicate Composer initialization.
phpstan.neon.dist Updates PHPStan settings.
examples/basic_file.yaml Adds declarative configuration example.
examples/basic_file.php Adds executable configuration example.
composer.json Updates dependencies and provider registrations.
Review details

Suppressed comments (1)

examples/basic_file.php:26

  • The two attribute keys contain an extra trailing quote (http.method" and http.route"), so the example emits non-standard attributes instead of the intended HTTP semantic-convention keys. Remove the stray quotes.
$child1->setAttribute('http.method"', 'GET');
$child1->setAttribute('http.route"', '/posts/:id');
  • Files reviewed: 29/29 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

public function updateSettings(Settings $settings): void
{
if ($settings->timestamp > ($this->settings?->timestamp ?? 0)) {
if ($settings->timestamp > ($this->settings->timestamp ?? 0)) {
public static function merge(Settings $remote, LocalSettings $local): Settings
{
$flags = $local->getTracingMode()?->value ?? $remote->flags;
$flags = $local->getTracingMode()->value ?? $remote->flags;
Comment on lines 30 to 36
public function __construct(
?string $namespace = null,
?string $pod_name = null,
?string $pod_uid = null,
?string $namespaceFile = null,
?string $mountInfoFile = null,
) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants