Skip to content

Commit

Permalink
DEV-19025: README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreznikoff committed Feb 7, 2025
1 parent b47bc4c commit 447caa7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ async def on_shutdown(app: Litestar):
stop_metrics()


def exception_handler(_: Request, exc: Exception):
def exception_handler(request: Request, exc: Exception):
"""
Important!
If you need to collect EXCEPTIONS metrics you should set it to exception_context here
If you need to collect `exceptions_total` metric you should set the
exception type name to exception_context
"""
status_code = getattr(exc, "status_code", HTTP_500_INTERNAL_SERVER_ERROR)
exception_type = type(exc).__name__
Expand Down Expand Up @@ -255,6 +256,21 @@ Current number of in-progress requests
* `method` - HTTP method like `GET`, `POST`
* `template_path` - path provided as a route

### exceptions_total

Total count of exceptions raised by path and exception type

**Type** Counter

**Labels**

* `service`
* `pod`
* `method` - HTTP method like `GET`, `POST`
* `template_path` - path provided as a route
* `exception_type` - exception type name


## Observe timing for custom methods

To collect metrics for some method (not FastAPI handlers) use `observe_metrics` decorator.
Expand Down

0 comments on commit 447caa7

Please sign in to comment.