Skip to content

NH-130745 - Suppress otel sdk autoloading - #270

Merged
jerrytfleung merged 13 commits into
mainfrom
suppress_otel_sdk
Nov 19, 2026
Merged

jerrytfleung merged 13 commits into
mainfrom
suppress_otel_sdk

Conversation

@jerrytfleung

@jerrytfleung jerrytfleung commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

This pull request updates the SolarWinds APM PHP SDK to use a new environment variable, SW_APM_AUTOLOAD_ENABLED, for controlling automatic SDK initialization, replacing the previous reliance on OTEL_PHP_AUTOLOAD_ENABLED. Documentation, code, and tests are updated to reflect this change, and some example configurations are simplified. Additionally, minor corrections and clarifications are made to documentation and example files.

Environment Variable and Autoloading Changes:

  • Introduced the SW_APM_AUTOLOAD_ENABLED environment variable for controlling autoloading, defaulting to true, and updated all references in code, tests, and documentation to use this variable instead of OTEL_PHP_AUTOLOAD_ENABLED. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
  • Updated integration and unit tests to use SW_APM_AUTOLOAD_ENABLED for enabling/disabling autoloading logic. [1] [2] [3] [4] [5] [6] [7] [8]

Documentation Updates:

  • Updated CONFIGURATION.md, README.md, and Azure/WordPress quickstart documentation to reference SW_APM_AUTOLOAD_ENABLED and clarify its usage, removing or updating references to OTEL_PHP_AUTOLOAD_ENABLED. [1] [2] [3] [4] [5]
  • Added a description of SW_APM_AUTOLOAD_ENABLED to the configuration tables and improved language for clarity.

Example and Sample Code Updates:

  • Removed or updated usage of OTEL_PHP_AUTOLOAD_ENABLED in all example scripts, aligning them with the new default behavior. [1] [2] [3] [4] [5] [6] [7]
  • Simplified example service key values in sample scripts for clarity. [1] [2] [3]

Miscellaneous:

  • Fixed the order of autoload files in composer.json to ensure correct loading sequence.
  • Cleaned up environment variable documentation in TROUBLESHOOTING.md to remove outdated references.
  • Added missing import for SolarwindsEnv alias in files where environment variable constants are referenced. [1] [2] [3]

These changes collectively ensure that the SolarWinds APM PHP SDK uses its own configuration variable for autoloading, improving clarity and reducing confusion with upstream OpenTelemetry variables.

Related issues

NH-130745

@jerrytfleung jerrytfleung changed the title Suppressed otel sdk loading NH-130745 - Suppress otel sdk autoloading Nov 19, 2026
@jerrytfleung
jerrytfleung requested a balanced review from Copilot November 19, 2026 01:21

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

The teardown no longer clears OTEL_PHP_AUTOLOAD_ENABLED, allowing leaked state to make subsequent autoload tests exercise different branches depending on execution order.

1 open issue
What changed in this PR

This PR gives the SolarWinds APM PHP SDK its own default-enabled autoload control, separating initialization from the upstream OpenTelemetry flag.

Changes:

  • Adds SW_APM_AUTOLOAD_ENABLED and updates initialization logic and tests.
  • Orders SolarWinds component registration before SDK autoloading.
  • Updates documentation and examples for default-enabled initialization and token-only service keys.
File Description
TROUBLESHOOTING.md Removes the upstream autoload flag from common settings.
tests/​Unit/​SdkAutoloaderTest.php Switches autoload tests to the SolarWinds flag.
tests/​Integration/​SdkAutoloaderIntegrationTest.php Updates initialization and root-span tests for the new flag.
src/​SdkAutoloader.php Uses the new flag and conditions reset on upstream autoloading.
src/​Common/​Configuration/​Variables.php Defines SW_APM_AUTOLOAD_ENABLED.
README.md Removes explicit upstream autoload activation from setup commands.
examples/​transactionNameAPI.php Relies on default autoloading and simplifies the service key.
examples/​other.php Relies on default autoloading and simplifies the service key.
examples/​basic.php Relies on default autoloading and simplifies the service key.
examples/​basic_file.php Removes explicit upstream autoload activation.
docs/​azure-app-service-quickstart.md Removes the upstream autoload app setting.
CONFIGURATION.md Documents the new flag and default autoload behavior.
composer.json Registers custom components before SDK initialization.

Review effort: Balanced

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

The default-enabled startup path lacks targeted fresh-process coverage verifying behavior with both autoload variables unset, including SDK configuration and propagator installation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Add fresh-process coverage for default-enabled startup

src/​SdkAutoloader.php:349

The new default-enabled startup path has no targeted coverage: the tests set explicit true/false values, and PHPUnit loads vendor/autoload.php before test setup. Add a fresh-process test that genuinely unsets both autoload variables before requiring Composer's autoloader. Assert that isEnabled() returns true and the expected SolarWinds SDK configuration and propagators are installed, rather than checking only autoload()'s return value.

1 resolved since last review

Review effort: Balanced

@jerrytfleung

Copy link
Copy Markdown
Contributor Author

🔵 Needs a closer look

The default-enabled startup path lacks targeted fresh-process coverage verifying behavior with both autoload variables unset, including SDK configuration and propagator installation.

No open issues 🎉

1 previously missed issue
In code that hasn't changed since last review

Medium severity Add fresh-process coverage for default-enabled startup
src/​SdkAutoloader.php:349

The new default-enabled startup path has no targeted coverage: the tests set explicit true/false values, and PHPUnit loads vendor/autoload.php before test setup. Add a fresh-process test that genuinely unsets both autoload variables before requiring Composer's autoloader. Assert that isEnabled() returns true and the expected SolarWinds SDK configuration and propagators are installed, rather than checking only autoload()'s return value.

1 resolved since last review

Review effort: Balanced

SW_APM_AUTOLOAD_ENABLED is true by default and OTEL_PHP_AUTOLOAD_ENABLED is false by default in upstream.

@jerrytfleung
jerrytfleung marked this pull request as ready for review November 19, 2026 03:02
@jerrytfleung
jerrytfleung requested review from a team as code owners November 19, 2026 03:02
@jerrytfleung
jerrytfleung marked this pull request as draft November 19, 2026 03:05

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.

🔵 Needs a closer look

The tests explicitly enable the SolarWinds flag, leaving default-enabled behavior when SW_APM_AUTOLOAD_ENABLED is genuinely unset unverified and allowing regressions to pass unnoticed.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Add coverage for the unset SolarWinds flag default

tests/​Unit/​SdkAutoloaderTest.php:40

The new default-enabled behavior is not covered: every test that expects initialization explicitly sets the SolarWinds flag to true. Removing the default argument from isEnabled() could therefore disable initialization for all the updated examples without failing these tests. Please also assert that isEnabled() returns true when SW_APM_AUTOLOAD_ENABLED is genuinely unset (rather than set to an empty string).

Review effort: Balanced

@jerrytfleung

Copy link
Copy Markdown
Contributor Author

🔵 Needs a closer look

The tests explicitly enable the SolarWinds flag, leaving default-enabled behavior when SW_APM_AUTOLOAD_ENABLED is genuinely unset unverified and allowing regressions to pass unnoticed.

No open issues 🎉

1 previously missed issue
In code that hasn't changed since last review

Medium severity Add coverage for the unset SolarWinds flag default
tests/​Unit/​SdkAutoloaderTest.php:40

The new default-enabled behavior is not covered: every test that expects initialization explicitly sets the SolarWinds flag to true. Removing the default argument from isEnabled() could therefore disable initialization for all the updated examples without failing these tests. Please also assert that isEnabled() returns true when SW_APM_AUTOLOAD_ENABLED is genuinely unset (rather than set to an empty string).

Review effort: Balanced

Added tests

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

The integration test does not exercise default-on entrypoint initialization in a fresh process or verify that global providers and propagators match the configuration.

1 open issue

Review effort: Balanced

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.

🟢 Approval recommended

No active review issues are reported for the SolarWinds-specific autoload switch change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@jerrytfleung
jerrytfleung marked this pull request as ready for review November 19, 2026 05:14
Comment thread examples/basic.php

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.

Would it benefit user to add SW_APM_AUTOLOAD_ENABLED to the examples?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SW_APM_AUTOLOAD_ENABLED by default is true. It is an environment variable that let users to opt-out apm-php.

@tammy-baylis-swi tammy-baylis-swi 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.

Lgtm; just had an examples nit.

@jerrytfleung
jerrytfleung merged commit 44ccfd5 into main Nov 19, 2026
10 checks passed
@jerrytfleung
jerrytfleung deleted the suppress_otel_sdk branch November 19, 2026 16:51
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.

3 participants