Better ApmConfig behaviour including try-except#757
Merged
tammy-baylis-swi merged 8 commits intomainfrom Apr 16, 2026
Merged
Conversation
Merged
Contributor
There was a problem hiding this comment.
Pull request overview
Improves resiliency of SolarWindsApmConfig by adding extra exception handling around service key parsing/masking and configuration conversion, with accompanying unit tests intended to cover malformed/unexpected config shapes.
Changes:
- Add try/except guards in
SolarWindsApmConfigfor service key parsing/masking andto_configuration()token extraction. - Add/extend unit tests for malformed
SW_APM_SERVICE_KEYand non-string/empty service key scenarios. - Add defensive handling in config-file key conversion (
_snake_to_camel_case).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
solarwinds_apm/apm_config.py |
Adds defensive exception handling for service key parsing/masking and configuration conversion. |
tests/unit/test_apm_config/test_apm_config_service_name.py |
Adds a unit test intended to cover malformed service key behavior for service name calculation. |
tests/unit/test_apm_config/test_apm_config.py |
Adds tests intended to cover new exception handling paths for service key masking, updates, config-file loading, and to_configuration(). |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
cheempz
previously approved these changes
Apr 16, 2026
Contributor
cheempz
left a comment
There was a problem hiding this comment.
LGTM with minor nits. The thing that actually confused me a bit was the calculate_service_name_apm_proto naming but i see it mainly is to distinguish from "lambda mode" :)
| ): | ||
| mocker.patch.dict(os.environ, { | ||
| "SW_APM_SERVICE_KEY": "valid:service", | ||
| }) |
Contributor
There was a problem hiding this comment.
i suppose this env var setting isn't needed because we're forcing a non-string service key below in test_config.
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.
Relates to #756
Adds more exception handling to ApmConfig to prevent distro crashing instrumented app, even if theoretical... unless automated review insists it's dead code e.g. this comment