Skip to content

Commit

Permalink
Do not assume 'content-encoding' header is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Apr 24, 2024
1 parent 0cd0407 commit 62fd8da
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tiled/server/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,14 @@ def capture_request_metrics(request, response):
metrics["read"]["pack"]
)
if "compress" in metrics:
encoding = response.headers["content-encoding"]
COMPRESSION_DURATION.labels(
method=method, code=code, endpoint=endpoint, encoding=encoding
).observe(metrics["compress"]["dur"])
COMPRESSION_RATIO.labels(
method=method, code=code, endpoint=endpoint, encoding=encoding
).observe(metrics["compress"]["ratio"])
encoding = response.headers.get("content-encoding")
if encoding:
COMPRESSION_DURATION.labels(
method=method, code=code, endpoint=endpoint, encoding=encoding
).observe(metrics["compress"]["dur"])
COMPRESSION_RATIO.labels(
method=method, code=code, endpoint=endpoint, encoding=encoding
).observe(metrics["compress"]["ratio"])


@lru_cache()
Expand Down

0 comments on commit 62fd8da

Please sign in to comment.