You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently i don't think i can modify these variables because they are not initialized with the class
Proposed Solution
initialize the variables within the class, allow users to either add their own kwargs or add their own Counter, Histogram, Gauge
classPrometheusMiddleware(BaseHTTPMiddleware):
def__init__(self, app: ASGIApp, filter_unhandled_paths: bool=False,
counter_kwargs: Optional[Dict[str, Any]] =None,
histogram_kwargs: Optional[Dict[str, Any]] =None,
gauge_kwargs: Optional[Dict[str, Any]] =None) ->None:
super().__init__(app)
self.filter_unhandled_paths=filter_unhandled_paths# Default values, can be overridden by kwargscounter_kwargs=counter_kwargsor {}
histogram_kwargs=histogram_kwargsor {}
gauge_kwargs=gauge_kwargsor {}
self.REQUESTS=Counter(
"starlette_requests_total",
"Total count of requests by method and path.",
["method", "path_template"],
**counter_kwargs
)
self.RESPONSES=Counter(
"starlette_responses_total",
"Total count of responses by method, path and status codes.",
["method", "path_template", "status_code"],
**counter_kwargs
)
self.REQUESTS_PROCESSING_TIME=Histogram(
"starlette_requests_processing_time_seconds",
"Histogram of requests processing time by path (in seconds)",
["method", "path_template"],
**histogram_kwargs
)
self.EXCEPTIONS=Counter(
"starlette_exceptions_total",
"Total count of exceptions raised by path and exception type",
["method", "path_template", "exception_type"],
**counter_kwargs
)
self.REQUESTS_IN_PROGRESS=Gauge(
"starlette_requests_in_progress",
"Gauge of requests by method and path currently being processed",
["method", "path_template"],
**gauge_kwargs
)
or
classPrometheusMiddleware(BaseHTTPMiddleware):
def__init__(self, app: ASGIApp, filter_unhandled_paths: bool=False,
requests_counter: Optional[Counter] =None,
responses_counter: Optional[Counter] =None,
processing_time_histogram: Optional[Histogram] =None,
exceptions_counter: Optional[Counter] =None,
requests_in_progress_gauge: Optional[Gauge] =None) ->None:
super().__init__(app)
self.filter_unhandled_paths=filter_unhandled_paths# Use provided metrics or default to the ones defined belowself.REQUESTS=requests_counterorCounter(
"starlette_requests_total",
"Total count of requests by method and path.",
["method", "path_template"]
)
self.RESPONSES=responses_counterorCounter(
"starlette_responses_total",
"Total count of responses by method, path and status codes.",
["method", "path_template", "status_code"]
)
self.REQUESTS_PROCESSING_TIME=processing_time_histogramorHistogram(
"starlette_requests_processing_time_seconds",
"Histogram of requests processing time by path (in seconds)",
["method", "path_template"]
)
self.EXCEPTIONS=exceptions_counterorCounter(
"starlette_exceptions_total",
"Total count of exceptions raised by path and exception type",
["method", "path_template", "exception_type"]
)
self.REQUESTS_IN_PROGRESS=requests_in_progress_gaugeorGauge(
"starlette_requests_in_progress",
"Gauge of requests by method and path currently being processed",
["method", "path_template"]
)
The text was updated successfully, but these errors were encountered:
Problem statement:
I want to add extra buckets to the Histogram.
Currently i don't think i can modify these variables because they are not initialized with the class
Proposed Solution
initialize the variables within the class, allow users to either add their own kwargs or add their own Counter, Histogram, Gauge
or
The text was updated successfully, but these errors were encountered: