From 433f700985376461bbf84c339621c8d9f531970a Mon Sep 17 00:00:00 2001 From: Quinn Milionis Date: Tue, 6 May 2025 12:23:59 -0700 Subject: [PATCH 1/2] check legacy_ignore in any_sampling --- setup.py | 2 +- src/scout_apm/core/sampler.py | 2 ++ tests/unit/core/test_sampler.py | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b649c6fd..fcc86bf5 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( name="scout_apm", - version="3.3.0", + version="3.3.1", description="Scout Application Performance Monitoring Agent", long_description=long_description, long_description_content_type="text/markdown", diff --git a/src/scout_apm/core/sampler.py b/src/scout_apm/core/sampler.py index 21d29b8a..04f6c8a0 100644 --- a/src/scout_apm/core/sampler.py +++ b/src/scout_apm/core/sampler.py @@ -32,6 +32,7 @@ def __init__(self, config): self.ignore_endpoints = set( config.value("ignore_endpoints") + config.value("ignore") ) + self.legacy_ignore = set(config.value("ignore")) self.ignore_jobs = set(config.value("ignore_jobs")) self.endpoint_sample_rate = config.value("endpoint_sample_rate") self.job_sample_rate = config.value("job_sample_rate") @@ -48,6 +49,7 @@ def _any_sampling(self): or self.sample_endpoints or self.sample_jobs or self.ignore_endpoints + or self.legacy_ignore or self.ignore_jobs or self.endpoint_sample_rate is not None or self.job_sample_rate is not None diff --git a/tests/unit/core/test_sampler.py b/tests/unit/core/test_sampler.py index 9d4d0bd3..88475012 100644 --- a/tests/unit/core/test_sampler.py +++ b/tests/unit/core/test_sampler.py @@ -168,3 +168,30 @@ def test_prefix_matching_precedence(config): # VIP users API should always be sampled assert sampler.should_sample("Controller/api/users/vip/list", False) is True + + +def test_should_sample_with_legacy_ignore(config): + """Test that sampling works correctly when only legacy 'ignore' config is set.""" + config.set( + sample_rate=100, # Return config to defaults + sample_endpoints={}, + sample_jobs={}, + ignore_endpoints=[], # No explicit ignore_endpoints + ignore_jobs=[], + ignore=["metrics", "health"], # Only set legacy ignore patterns + endpoint_sample_rate=None, + job_sample_rate=None, + ) + sampler = Sampler(config) + + # Legacy ignored endpoints should not be sampled + assert sampler.should_sample("Controller/metrics/stats", False) is False + assert sampler.should_sample("Controller/health/check", False) is False + + # Legacy ignore should be combined with ignore_endpoints + assert "metrics" in sampler.ignore_endpoints + assert "health" in sampler.ignore_endpoints + + # Non-ignored endpoints and jobs should be sampled + assert sampler.should_sample("Controller/users/list", False) is True + assert sampler.should_sample("Job/process_data", False) is True From c85f0be5e7752ff39acebd3593d8c70432a78b66 Mon Sep 17 00:00:00 2001 From: Quinn Milionis Date: Tue, 6 May 2025 12:45:50 -0700 Subject: [PATCH 2/2] bump artifact actions to v4 --- .github/workflows/release.yml | 8 ++++---- src/scout_apm/core/sampler.py | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2319539..bd95fec4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,7 +47,7 @@ jobs: CIBW_ARCHS_LINUX: "auto aarch64" run: python -m cibuildwheel - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./wheelhouse/*.whl @@ -72,7 +72,7 @@ jobs: CIBW_ARCHS_MACOS: "x86_64 arm64" run: python -m cibuildwheel - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./wheelhouse/*.whl @@ -98,7 +98,7 @@ jobs: SCOUT_DISABLE_EXTENSIONS: "1" run: python setup.py bdist_wheel - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: dist/*.whl @@ -116,7 +116,7 @@ jobs: - name: Build sdist run: python setup.py sdist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: dist/*.tar.gz diff --git a/src/scout_apm/core/sampler.py b/src/scout_apm/core/sampler.py index 04f6c8a0..21d29b8a 100644 --- a/src/scout_apm/core/sampler.py +++ b/src/scout_apm/core/sampler.py @@ -32,7 +32,6 @@ def __init__(self, config): self.ignore_endpoints = set( config.value("ignore_endpoints") + config.value("ignore") ) - self.legacy_ignore = set(config.value("ignore")) self.ignore_jobs = set(config.value("ignore_jobs")) self.endpoint_sample_rate = config.value("endpoint_sample_rate") self.job_sample_rate = config.value("job_sample_rate") @@ -49,7 +48,6 @@ def _any_sampling(self): or self.sample_endpoints or self.sample_jobs or self.ignore_endpoints - or self.legacy_ignore or self.ignore_jobs or self.endpoint_sample_rate is not None or self.job_sample_rate is not None