INNER CODE UNIT · Python
response_body_size_count
stephenhillier/starlette_exporter · starlette_exporter/middleware.py:229
def response_body_size_count(self):
"""
Optional metric for tracking the size of response bodies.
If using gzip middleware, you should test that the starlette_exporter middleware computes
the proper response size value. Please post any feedback on this metric as an issue
at https://github.com/stephenhillier/starlette_exporter.
"""
if (
self.optional_metrics_list is not None
and optional_metrics.response_body_size in self.optional_metrics_list
):
metric_name = f"{self.prefix}_response_body_bytes_total"
if metric_name not in PrometheusMiddleware._metrics:
PrometheusMiddleware._metrics[metric_name] = Counter(
metric_name,
"Total HTTP response body bytes",
(