Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce cardinality in api metrics to keep from blowing up prometheus #421

Merged
merged 6 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions iceprod/prom_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class HistogramBuckets:
# DEFAULT = [.005, .01, .025, .05, .075, .1, .25, .5, .75, 1, 2.5, 5, 7.5, 10]

#: Database bucket centered around 5ms, with outliers up to 10s
DB = [.001, .002, .003, .004, .005, .006, .007, .008, .009, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10]
DB = [.001, .0025, .005, .0075, .01, .025, .05, .1, .25, .5, 1, 10]

#: API bucket centered around 50ms, up to 10s
API = [.005, .01, .02, .03, .04, .05, .06, .07, .08, .09, .1, .25, .5, .75, 1, 2.5, 5, 7.5, 10]
API = [.005, .01, .025, .04, .05, .06, .075, .1, .25, .5, 1, 5, 10]

#: Timer bucket up to 1 second
SECOND = [.0001, .0005, .001, .0025, .005, .0075, .01, .025, .05, .075, .1, .25, .5, .75, 1]
Expand All @@ -36,7 +36,7 @@ class HistogramBuckets:


class PromRequestMixin:
PromHTTPHistogram = Histogram('http_request_duration_seconds', 'HTTP request duration in seconds', labelnames=('verb', 'path', 'status'), buckets=HistogramBuckets.API)
PromHTTPHistogram = Histogram('http_request_duration_seconds', 'HTTP request duration in seconds', labelnames=('method', 'handler', 'status'), buckets=HistogramBuckets.API)

def prepare(self):
super().prepare()
Expand All @@ -46,9 +46,9 @@ def on_finish(self):
super().on_finish()
end_time = time.monotonic()
self.PromHTTPHistogram.labels(
verb=self.request.method,
path=self.request.path,
status=self.get_status(),
method=str(self.request.method).lower(),
handler=f'{self.__class__.__module__.split(".")[-1]}.{self.__class__.__name__}',
status=str(self.get_status()),
).observe(end_time - self._prom_start_time)


Expand Down
6 changes: 3 additions & 3 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ attrs==25.1.0
# referencing
babel==2.17.0
# via sphinx
boto3==1.36.14
boto3==1.36.15
# via iceprod (setup.py)
botocore==1.36.14
botocore==1.36.15
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -50,7 +50,7 @@ exceptiongroup==1.2.2
# via anyio
h11==0.14.0
# via httpcore
htcondor==24.3.0
htcondor==24.4.0
# via iceprod (setup.py)
httpcore==1.0.7
# via httpx
Expand Down
6 changes: 3 additions & 3 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ attrs==25.1.0
# referencing
beautifulsoup4==4.13.3
# via iceprod (setup.py)
boto3==1.36.14
boto3==1.36.15
# via
# iceprod (setup.py)
# moto
botocore==1.36.14
botocore==1.36.15
# via
# boto3
# moto
Expand Down Expand Up @@ -60,7 +60,7 @@ flexmock==0.12.2
# via iceprod (setup.py)
h11==0.14.0
# via httpcore
htcondor==24.3.0
htcondor==24.4.0
# via iceprod (setup.py)
httpcore==1.0.7
# via httpx
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ attrs==25.1.0
# via
# jsonschema
# referencing
boto3==1.36.14
boto3==1.36.15
# via iceprod (setup.py)
botocore==1.36.14
botocore==1.36.15
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -44,7 +44,7 @@ exceptiongroup==1.2.2
# via anyio
h11==0.14.0
# via httpcore
htcondor==24.3.0
htcondor==24.4.0
# via iceprod (setup.py)
httpcore==1.0.7
# via httpx
Expand Down