Skip to content

Commit

Permalink
Merge pull request #437 from solarwinds/NH-92060-enabled-sqlcomment-c…
Browse files Browse the repository at this point in the history
…ase-insensitive

NH-92060 Allow case-insensitive instrumentor names when enabling sqlcomment
  • Loading branch information
tammy-baylis-swi authored Oct 1, 2024
2 parents 3423755 + e4d2350 commit 6abded3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions solarwinds_apm/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,13 @@ def get_enable_commenter_env_map(self) -> dict:
)
continue

if key in _SQLCOMMENTERS:
instrumentor_name = key.strip().lower()
if instrumentor_name in _SQLCOMMENTERS:
env_v_bool = SolarWindsApmConfig.convert_to_bool(
value.strip()
)
if env_v_bool is not None:
env_commenter_map[key.strip()] = env_v_bool
env_commenter_map[instrumentor_name] = env_v_bool

return env_commenter_map

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def test_get_enable_commenter_env_map_valid_ignored_values(self, mocker):
}

def test_get_enable_commenter_env_map_valid_mixed_case(self, mocker):
mocker.patch.dict(os.environ, {"SW_APM_ENABLED_SQLCOMMENT": "django=tRuE,flask=TrUe"})
mocker.patch.dict(os.environ, {"SW_APM_ENABLED_SQLCOMMENT": "dJAnGO=tRuE,FlaSK=TrUe"})
assert distro.SolarWindsDistro().get_enable_commenter_env_map() == {
"django": True,
"flask": True,
Expand All @@ -797,7 +797,7 @@ def test_get_enable_commenter_env_map_valid_mixed_case(self, mocker):
}

def test_get_enable_commenter_env_map_valid_whitespace_stripped(self, mocker):
mocker.patch.dict(os.environ, {"SW_APM_ENABLED_SQLCOMMENT": "django= true ,flask= true "})
mocker.patch.dict(os.environ, {"SW_APM_ENABLED_SQLCOMMENT": "django = true , flask= true "})
assert distro.SolarWindsDistro().get_enable_commenter_env_map() == {
"django": True,
"flask": True,
Expand Down

0 comments on commit 6abded3

Please sign in to comment.