Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the SolarWinds APM distribution against unexpected input/runtime failures by adding defensive exception handling in multiple parsing and sampling-related code paths, aiming to prevent the distro from crashing instrumented applications.
Changes:
- Add try/except guards around various header/config parsing and conversion operations (trace options, span/trace flags, HTTP status code, service key token extraction).
- Improve resiliency of sampling settings ingestion (JSON file/HTTP response parsing) and hostname discovery.
- Add targeted logging when exceptional/invalid inputs are encountered.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
solarwinds_apm/w3c_transformer.py |
Adds exception handling to span-id extraction from SW tracestate value. |
solarwinds_apm/traceoptions.py |
Adds guarded parsing of x-trace-options and more robust ts handling. |
solarwinds_apm/oboe/trace_options.py |
Wraps signature digest creation with exception handling and warning log. |
solarwinds_apm/oboe/sampler.py |
Guards HTTP status-code integer conversion when building span metadata. |
solarwinds_apm/oboe/oboe_sampler.py |
Guards parsing of trace flags from trace_state in parent-based sampling. |
solarwinds_apm/oboe/json_sampler.py |
Logs on invalid JSON settings file parse and re-raises. |
solarwinds_apm/oboe/http_sampler.py |
Adds hostname fallback on failure and catches JSON decode errors when parsing collector responses. |
solarwinds_apm/distro.py |
Guards service key split to avoid crashing on unexpected types. |
solarwinds_apm/apm_logging.py |
Guards parsing of SW_APM_DEBUG_LEVEL to avoid exceptions. |
…ral' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
cheempz
approved these changes
Apr 16, 2026
Contributor
cheempz
left a comment
There was a problem hiding this comment.
LGTM and agree on the reverted change for json_sampler, since _read() is called in an already guarded try/except that would catch the decode error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds more exception handling to prevent distro crashing instrumented app, even if theoretical. Logs warning or debug, depending on similar existing logs. Adds a bit of test coverage.
What do you think of this?: I'm keeping the
raisein JsonSampler (restored in fcfb05c) because something is very wrong with the environment. Or, we can log anerroronce and return[].Will be doing an apm_config update in a separate PR because that needs some extra test coverage: #757