Skip to content

Internal - Move sampling configs to sampler component config - #661

Merged
cleverchuk merged 2 commits into
mainfrom
cc/NH-153394
Oct 30, 2026
Merged

cleverchuk merged 2 commits into
mainfrom
cc/NH-153394

Conversation

@cleverchuk

Copy link
Copy Markdown
Contributor

This pull request introduces a new HTTP-based sampler component provider for the OpenTelemetry SolarWinds agent, enabling more flexible and isolated configuration of sampling settings, including support for per-sampler collector, service key, and proxy settings. It also refactors HttpSettingsReader and HttpSettingsReaderDelegate to support this flexibility and adds comprehensive tests for the new functionality.

Key changes:

New HTTP Sampler Component Provider

  • Added HttpSamplerComponentProvider, a new ComponentProvider implementation that allows configuring a sampler with its own collector, service key, and proxy settings, independent of the global agent configuration. It validates configuration, parses proxy settings, and constructs the appropriate settings fetcher.

  • Added a full test suite for HttpSamplerComponentProvider, verifying correct configuration parsing, isolation from global agent config, proxy handling, and error handling for invalid configs.

Refactoring for Configurability and Testability

  • Refactored HttpSettingsReader to support two construction modes: one using system/global config (forSystemConfig) and another for explicit file/scoped config (forFileConfig). This allows samplers to use their own collector/service key, with sensible defaults if not provided.

  • Refactored HttpSettingsReaderDelegate to accept a ProxyConfig via constructor, enabling per-sampler proxy settings instead of always using the global config. The proxy is now supplied as a functional interface, improving testability and configurability. [1] [2]

Testing Enhancements

  • Added and updated tests for HttpSettingsReader and HttpSettingsReaderDelegate to verify correct use of per-sampler collector, service key, and proxy settings, as well as default fallbacks. [1] [2]

Integration and Initialization Improvements

  • Updated agent initialization logic to use the new HttpSettingsReader.forSystemConfig method and ensure that settings are only initialized once, preventing redundant initialization.

  • Ensured settings are reset on shutdown to avoid stale state between runs.

Test services data

  1. e-1712644058766987264
  2. e-1712643928659124224
  3. e-1742334541200846848
  4. e-1777406072376840192

Copilot AI balanced review requested due to automatic review settings October 28, 2026 20:14
@cleverchuk
cleverchuk requested review from a team as code owners October 28, 2026 20:15

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 sampler regressions break existing configurations and initialization, while shared settings and stale fetcher callbacks can apply incorrect sampling policies.

10 open issues
What changed in this PR

Moves declarative sampling configuration into dedicated HTTP and JSON sampler components for the standard and Lambda agents.

Changes:

  • Adds sampler providers with component-level settings and validation, replacing the shared swo/sampler provider and legacy sampling parsers.
  • Separates HTTP collector, service-key, and proxy configuration from global agent settings.
  • Updates settings initialization, fetcher replacement, tests, and YAML fixtures.
File Description
smoke-tests/​sdk-config.yaml Migrates the fallback sampler and transaction rules to swo_http.
libs/​shared/​src/​test/​resources/​sdk-config.yaml Uses component-level sampling settings.
libs/​shared/​src/​test/​resources/​sdk-config-bad-transaction-settings-1.yaml Removes an obsolete invalid-config fixture.
libs/​shared/​src/​test/​resources/​sdk-config-bad-transaction-settings-0.yaml Removes an obsolete invalid-config fixture.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​SharedConfigCustomizerProviderTest.java Updates expectations for omitted samplers.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​SamplerComponentProviderTest.java Removes the legacy provider test.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​AbstractSamplerComponentProviderTest.java Tests shared sampling configuration and validation.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​UrlSampleRateConfigParserTest.java Removes tests for the retired URL-rate parser.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​TriggerTraceParserTest.java Removes tests for the retired trigger-trace parser.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​TransactionSettingsConfigParserTest.java Removes tests for the retired transaction parser.
libs/​shared/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​TracingModeParserTest.java Removes tests for the retired tracing-mode parser.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​SharedNames.java Defines HTTP and JSON sampler names.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​SharedConfigCustomizerProvider.java Removes automatic default sampler injection.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​SamplerComponentProvider.java Removes the legacy sampler provider.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​AbstractSamplerComponentProvider.java Centralizes component-level sampling parsing and initialization.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​UrlSampleRateConfigParser.java Moves URL-rate parsing out of global configuration.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​TriggerTraceParser.java Removes global trigger-trace parsing.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​TransactionSettingsConfigParser.java Moves transaction parsing into the sampler provider.
libs/​shared/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​parser/​yaml/​TracingModeParser.java Removes global tracing-mode parsing.
libs/​sampling/​src/​test/​java/​com/​solarwinds/​joboe/​sampling/​SettingsManagerTest.java Tests fetcher replacement, reset, and waiting behavior.
libs/​sampling/​src/​main/​java/​com/​solarwinds/​joboe/​sampling/​SettingsManager.java Adds initialization checks, reset, and fetcher cleanup.
libs/​lambda/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​JsonSamplerComponentProviderTest.java Tests JSON sampler file selection and validation.
libs/​lambda/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​LambdaAgentListener.java Preserves initialized settings and resets disabled-agent state.
libs/​lambda/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​JsonSamplerComponentProvider.java Adds the file-backed swo_json sampler provider.
libs/​lambda/​build.gradle.kts Adds declarative configuration dependencies.
custom/​src/​test/​resources/​sdk-config.yaml Migrates tracing mode to swo_http.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​HttpSamplerComponentProviderTest.java Tests HTTP sampler settings, isolation, and validation.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​HttpSettingsReaderTest.java Tests scoped reader values and defaults.
custom/​src/​test/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​HttpSettingsReaderDelegateTest.java Tests explicit proxy and no-proxy configuration.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​SolarwindsAgentListener.java Avoids replacing initialized settings and uses the system-config reader.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​provider/​HttpSamplerComponentProvider.java Adds HTTP sampler configuration and fetcher construction.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​HttpSettingsReaderDelegate.java Supports explicitly supplied proxy settings.
custom/​src/​main/​java/​com/​solarwinds/​opentelemetry/​extensions/​config/​HttpSettingsReader.java Separates system-backed and explicitly scoped configuration.

Review effort: Balanced

@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 4c2d284 into main Oct 30, 2026
17 checks passed
@cleverchuk
cleverchuk deleted the cc/NH-153394 branch October 30, 2026 17:05
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