Skip to content

Commit 6cecd0d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6c16765 commit 6cecd0d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/backend/app/monitoring.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
log = logging.getLogger(__name__)
3030

31+
3132
def add_endpoint_profiler(app: Litestar) -> None:
3233
"""Add a simple per-request profiler middleware when DEBUG is enabled.
3334
@@ -97,31 +98,31 @@ async def send_wrapper(message: dict[str, Any]) -> None:
9798
# Register middleware with the Litestar app
9899
app.middleware.append(profiler_middleware)
99100

101+
100102
from urllib.parse import urlparse
101103

102104
# Endpoints that should not create tracing or error noise
103105
IGNORED_PATHS = {
104106
"/robots.txt",
105107
}
106108

109+
107110
def traces_sampler(sampling_context: dict) -> float:
108-
"""
109-
Determine if an incoming request should be traced.
111+
"""Determine if an incoming request should be traced.
110112
Returns 0.0 to ignore, 1.0 to trace.
111113
"""
112114
scope = sampling_context.get("asgi_scope")
113-
115+
114116
if scope:
115117
path = scope.get("path", "")
116118
if path in IGNORED_PATHS:
117119
return 0.0
118120

119121
return 1.0
120122

123+
121124
def before_send(event: dict, hint: dict) -> dict | None:
122-
"""
123-
Filter out specific error events before they are sent to Sentry.
124-
"""
125+
"""Filter out specific error events before they are sent to Sentry."""
125126
request = event.get("request", {})
126127
url = request.get("url")
127128

@@ -132,10 +133,9 @@ def before_send(event: dict, hint: dict) -> dict | None:
132133

133134
return event
134135

136+
135137
def set_sentry_otel_tracer(dsn: str) -> None:
136-
"""
137-
Initialize Sentry with OpenTelemetry integration.
138-
"""
138+
"""Initialize Sentry with OpenTelemetry integration."""
139139
if not dsn:
140140
return
141141

@@ -296,4 +296,3 @@ def get_otel_plugin():
296296
from litestar.contrib.opentelemetry import OpenTelemetryConfig, OpenTelemetryPlugin
297297

298298
return OpenTelemetryPlugin(OpenTelemetryConfig())
299-

0 commit comments

Comments
 (0)