Repository: scoutapp/scout_apm_python

Issue:
Config to capture query string, not just path
When a request comes in, we capture `request.path`, which doesn't appear to capture any query string.

We should match the Ruby agent:
* Default to capturing the entire path and query string
* Config to not capture query string https://docs.scoutapm.com/#uri_reporting

Discussion:

Patch:
diff --git a/src/scout_apm/core/config.py b/src/scout_apm/core/config.py
index 200968d..5d77b7b 100644
--- a/src/scout_apm/core/config.py
+++ b/src/scout_apm/core/config.py
@@ -233,6 +233,7 @@ class ScoutConfigDefaults(object):
             "name": "",
             "revision_sha": self._git_revision_sha(),
             "scm_subdirectory": "",
+            "uri_reporting": "filtered_params",
         }
 
     def _git_revision_sha(self):
diff --git a/src/scout_apm/core/web_requests.py b/src/scout_apm/core/web_requests.py
index 4e2b89e..52ff42d 100644
--- a/src/scout_apm/core/web_requests.py
+++ b/src/scout_apm/core/web_requests.py
@@ -1,5 +1,6 @@
 # coding=utf-8
 from scout_apm.compat import urlencode
+from scout_apm.core.context import AgentContext
 
 # Originally derived from:
 # 1. Rails:
@@ -35,6 +36,8 @@ FILTER_PARAMETERS = frozenset(
 
 
 def create_filtered_path(path, query_params):
+    if AgentContext.instance.config.value("uri_reporting") == "path":
+        return path
     filtered_params = sorted(
         (
             (k, "[FILTERED]" if k.lower() in FILTER_PARAMETERS else v)


Test patch:
diff --git a/tests/unit/core/test_web_requests.py b/tests/unit/core/test_web_requests.py
index af36d4e..ffe9f0c 100644
--- a/tests/unit/core/test_web_requests.py
+++ b/tests/unit/core/test_web_requests.py
@@ -3,9 +3,17 @@ from __future__ import absolute_import, division, print_function, unicode_litera
 
 import pytest
 
+from scout_apm.core.context import AgentContext
 from scout_apm.core.web_requests import create_filtered_path
 
 
+@pytest.fixture(autouse=True)
+def force_context():
+    # Since this function accesses the context, it needs to always be built
+    # TODO: remove when moving to a sensible singleton pattern
+    AgentContext.build()
+
+
 @pytest.mark.parametrize(
     "path, params, expected",
     [
@@ -25,3 +33,14 @@ from scout_apm.core.web_requests import create_filtered_path
 )
 def test_create_filtered_path(path, params, expected):
     assert create_filtered_path(path, params) == expected
+
+
+@pytest.mark.parametrize("path, params", [("/", []), ("/", [("foo", "ignored")])])
+def test_create_filtered_path_path(path, params):
+    # If config filtered_params is set to "path", expect we always get the path
+    # back
+    AgentContext.instance.config.set(uri_reporting="path")
+    try:
+        assert create_filtered_path(path, params) == path
+    finally:
+        AgentContext.instance.config.reset_all()