Skip to content

Better ApmConfig behaviour including try-except#757

Merged
tammy-baylis-swi merged 8 commits intomainfrom
apm-config-improvements
Apr 16, 2026
Merged

Better ApmConfig behaviour including try-except#757
tammy-baylis-swi merged 8 commits intomainfrom
apm-config-improvements

Conversation

@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Apr 14, 2026

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

@tammy-baylis-swi tammy-baylis-swi requested review from a team as code owners April 14, 2026 20:42
Copilot AI review requested due to automatic review settings April 14, 2026 20:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SolarWindsApmConfig for service key parsing/masking and to_configuration() token extraction.
  • Add/extend unit tests for malformed SW_APM_SERVICE_KEY and 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().

Comment thread tests/unit/test_apm_config/test_apm_config.py Outdated
Comment thread tests/unit/test_apm_config/test_apm_config.py Outdated
Comment thread solarwinds_apm/apm_config.py Outdated
Comment thread solarwinds_apm/apm_config.py Outdated
Comment thread solarwinds_apm/apm_config.py Outdated
Comment thread solarwinds_apm/apm_config.py
Comment thread tests/unit/test_apm_config/test_apm_config_service_name.py Outdated
Comment thread tests/unit/test_apm_config/test_apm_config.py Outdated
Comment thread tests/unit/test_apm_config/test_apm_config.py Outdated
cheempz
cheempz previously approved these changes Apr 16, 2026
Copy link
Copy Markdown
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

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" :)

Comment thread solarwinds_apm/apm_config.py Outdated
):
mocker.patch.dict(os.environ, {
"SW_APM_SERVICE_KEY": "valid:service",
})
Copy link
Copy Markdown
Contributor

@cheempz cheempz Apr 16, 2026

Choose a reason for hiding this comment

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

i suppose this env var setting isn't needed because we're forcing a non-string service key below in test_config.

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.

Removed in b229f88

Copy link
Copy Markdown
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

👍

@tammy-baylis-swi tammy-baylis-swi merged commit 749032c into main Apr 16, 2026
64 checks passed
@tammy-baylis-swi tammy-baylis-swi deleted the apm-config-improvements branch April 16, 2026 22:52
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