mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: remove HEAD and OPTIONS handling from metrics
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
790ca4194a
commit
afd25c248f
1 changed files with 8 additions and 2 deletions
|
@ -60,6 +60,9 @@ def http_requests_total() -> Callable[[Info], None]:
|
||||||
labelnames=("method", "path", "status"))
|
labelnames=("method", "path", "status"))
|
||||||
|
|
||||||
def instrumentation(info: Info) -> None:
|
def instrumentation(info: Info) -> None:
|
||||||
|
if info.request.method.lower() in ("head", "options"): # pragma: no cover
|
||||||
|
return
|
||||||
|
|
||||||
scope = info.request.scope
|
scope = info.request.scope
|
||||||
|
|
||||||
# Taken from https://github.com/stephenhillier/starlette_exporter
|
# Taken from https://github.com/stephenhillier/starlette_exporter
|
||||||
|
@ -70,8 +73,8 @@ def http_requests_total() -> Callable[[Info], None]:
|
||||||
if not (scope.get("endpoint", None) and scope.get("router", None)):
|
if not (scope.get("endpoint", None) and scope.get("router", None)):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
root_path = scope.get("root_path", "")
|
root_path = scope.get("root_path", str())
|
||||||
app = scope.get("app", {})
|
app = scope.get("app", dict())
|
||||||
|
|
||||||
if hasattr(app, "root_path"):
|
if hasattr(app, "root_path"):
|
||||||
app_root_path = getattr(app, "root_path")
|
app_root_path = getattr(app, "root_path")
|
||||||
|
@ -102,6 +105,9 @@ def http_api_requests_total() -> Callable[[Info], None]:
|
||||||
labelnames=("type", "status"))
|
labelnames=("type", "status"))
|
||||||
|
|
||||||
def instrumentation(info: Info) -> None:
|
def instrumentation(info: Info) -> None:
|
||||||
|
if info.request.method.lower() in ("head", "options"): # pragma: no cover
|
||||||
|
return
|
||||||
|
|
||||||
if info.request.url.path.rstrip("/") == "/rpc":
|
if info.request.url.path.rstrip("/") == "/rpc":
|
||||||
type = info.request.query_params.get("type", "None")
|
type = info.request.query_params.get("type", "None")
|
||||||
if info.response:
|
if info.response:
|
||||||
|
|
Loading…
Add table
Reference in a new issue