Skip to content

Commit

Permalink
Apply statsd arg sanitization to all pages
Browse files Browse the repository at this point in the history
The previous sanitization would only run on the `or` portion.
  • Loading branch information
mvdbeek committed Jul 8, 2024
1 parent 0d0e2a1 commit ddf7883
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/galaxy/web/framework/middleware/statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ def __call__(self, environ, start_response):
start_time = time.time()
req = self.application(environ, start_response)
dt = int((time.time() - start_time) * 1000)
page = (
environ.get("controller_action_key", None)
or environ.get("PATH_INFO", "NOPATH")
.strip("/")
.replace("/", ".")
.encode("ascii", errors="replace")
.decode()
)
self.galaxy_stasd_client.timing(page, dt)
page = environ.get("controller_action_key", None) or environ.get("PATH_INFO", "NOPATH")
sanitized_page = page.strip("/").replace("/", ".").encode("ascii", errors="replace").decode()
self.galaxy_stasd_client.timing(sanitized_page, dt)
try:
times = QUERY_COUNT_LOCAL.times
self.galaxy_stasd_client.timing(f"sql.{page}", sum(times) * 1000.0)
self.galaxy_stasd_client.incr(f"sqlqueries.{page}", len(times))
self.galaxy_stasd_client.timing(f"sql.{sanitized_page}", sum(times) * 1000.0)
self.galaxy_stasd_client.incr(f"sqlqueries.{sanitized_page}", len(times))
except AttributeError:
# Not logging query counts, skip
pass
Expand Down

0 comments on commit ddf7883

Please sign in to comment.