Skip to content

Fix - Have the Solarwinds sampler start settings polling - #687

Merged
cleverchuk merged 1 commit into
mainfrom
cc/NH-153775
Nov 20, 2026
Merged

cleverchuk merged 1 commit into
mainfrom
cc/NH-153775

Conversation

@cleverchuk

Copy link
Copy Markdown
Contributor

TL;DR

The agent polled the settings endpoint (getSettings) every 60s even when the Solarwinds sampler was not in use, e.g. when a declarative config file selected a different sampler. Settings polling is now owned by SolarwindsSampler: the fetcher is started when the sampler is constructed, so no Solarwinds sampler means no polling. This PR also disables the SDK up front when the agent config fails to load, and recognizes otel.config.file as enabling declarative config.

Why

  • Settings were started from the agent listeners after SDK startup, independent of which sampler was configured. In declarative mode, the sampler component provider initialized settings only for the Solarwinds sampler, but the listeners then started a fallback HTTP (or Lambda file) fetcher whenever settings were not initialized, which is exactly the case for a non-Solarwinds sampler.
  • Settings exist only to drive the Solarwinds sampler's trace decisions, so the sampler is the natural owner of their lifecycle.

Changes

  • Sampler owns its settings. SolarwindsSampler now has a single constructor taking a SettingsFetcher and SamplingConfiguration, which initializes SettingsManager. The no-arg constructor is removed, so a sampler cannot exist without a settings source.
  • Creators supply the fetcher.
    • Declarative: the sampler component providers pass the fetcher they already build.
    • Autoconfigure (agent): the tracer provider customizer passes an HTTP fetcher (60s interval). The fetcher factory is injectable for tests.
    • Autoconfigure (Lambda): the tracer provider customizer passes the file-based fetcher.
  • Listeners no longer start a fetcher. The agent listener still waits on the settings latch when a sampler has started one.
  • Disabled agent. When the agent config fails to load, both autoconfigure providers set otel.sdk.disabled=true and skip customization, instead of letting the SDK start and shutting it down in the listener afterwards. The Lambda provider now loads its config in customize() rather than in a static initializer.
  • Declarative config detection. The legacy config loader is skipped when either otel.config.file or otel.experimental.config.file is set (previously only the experimental key).

Testing

  • Sampler: constructing it initializes SettingsManager, and settings are served from the supplied fetcher.
  • Agent and Lambda tracer provider customizers: attaching the sampler starts settings fetching. With the agent disabled, no sampler is attached and nothing is fetched.
  • Both autoconfigure providers: a config-load failure disables the agent, sets otel.sdk.disabled and registers no customizations.
  • Config loader: legacy config loading is skipped when either config-file property is set on its own.

@cleverchuk
cleverchuk requested review from a team as code owners November 20, 2026 17:40
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:40

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

Validation with the actual OTel agent is still needed because mocked tests do not verify polling safety during tracer-provider customization or SDK disablement before initialization when configuration loading fails.

No open issues 🎉

What changed in this PR

Moves settings-fetcher startup into SolarwindsSampler, so settings polling depends on the sampler being constructed rather than agent startup.

Changes:

  • Pass HTTP or Lambda file-based fetchers into the sampler and remove listener-owned initialization.
  • Disable the SDK when agent configuration fails to load and recognize both declarative configuration property names.
  • Update tests for sampler initialization, disabled-agent behavior, and configuration detection.
File Description
spotbugs-exclude.xml Extend the static-field-write exclusion to the Lambda configuration provider.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsSamplerTest.java Verify construction initializes settings with the supplied fetcher.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsSampler.java Require a fetcher and sampling configuration; initialize settings on construction.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​AbstractSamplerComponentProvider.java Pass declarative settings directly to the sampler constructor.
libs/​lambda/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​TraceProviderCustomizerTest.java Verify sampler attachment initializes settings.
libs/​lambda/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​LambdaAgentListenerTest.java Remove expectations for listener-owned initialization and shutdown.
libs/​lambda/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​DefaultAutoConfigurationCustomizerProviderTest.java Test SDK disabling after configuration-load failure.
libs/​lambda/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​TraceProviderCustomizer.java Supply the Lambda file-based settings fetcher.
libs/​lambda/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​LambdaAgentListener.java Remove settings initialization and post-startup SDK shutdown.
libs/​lambda/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​DefaultAutoConfigurationCustomizerProvider.java Load configuration during customization and disable the SDK on failure.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsTracerProviderCustomizerTest.java Test settings initialization and disabled-agent behavior using an injected fetcher.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsAgentListenerTest.java Remove the obsolete listener shutdown test.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​provider/​AutoConfigurationCustomizerProviderImplTest.java Verify configuration failure disables the SDK and skips customization.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​ConfigurationLoaderTest.java Test legacy-loader bypass for both declarative configuration keys.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsTracerProviderCustomizer.java Supply an HTTP fetcher through an injectable factory.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsAgentListener.java Remove fallback polling startup while retaining settings-latch waiting.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​AutoConfigurationCustomizerProviderImpl.java Set otel.sdk.disabled when configuration loading fails.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​ConfigurationLoader.java Recognize otel.config.file alongside the experimental property.

Review effort: Balanced

Settings were fetched by the agent listeners regardless of the configured
sampler, so a non-Solarwinds sampler (e.g. via declarative config) still
triggered getSettings polling. The sampler now owns its settings fetcher:
SolarwindsSampler initializes SettingsManager on construction, and the
listeners no longer start a fetcher.

When the agent config fails to load, disable the SDK via otel.sdk.disabled
instead of shutting it down after startup, and recognize otel.config.file
for declarative config.

@cheempz cheempz 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

@jerrytfleung jerrytfleung left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@cleverchuk
cleverchuk merged commit 95cea69 into main Nov 20, 2026
17 checks passed
@cleverchuk
cleverchuk deleted the cc/NH-153775 branch November 20, 2026 21:01
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.

4 participants