From d23f73fc019ab220ffc58d6512749d7f2884eca5 Mon Sep 17 00:00:00 2001 From: Evan Morris Date: Thu, 24 Oct 2024 01:04:41 -0400 Subject: [PATCH] trying to fix excluded urls --- Automat/automat/server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Automat/automat/server.py b/Automat/automat/server.py index fa04ffc..331d3ee 100644 --- a/Automat/automat/server.py +++ b/Automat/automat/server.py @@ -33,6 +33,8 @@ async def __call__(self, scope, receive, send): from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware + from opentelemetry.util.http import ExcludeList + # from opentelemetry.instrumentation.aiohttp_client import AioHttpClientInstrumentor # would need requirement like opentelemetry-instrumentation-aiohttp-client==0.48b0 @@ -55,6 +57,10 @@ async def __call__(self, scope, receive, send): provider.add_span_processor(processor) trace.set_tracer_provider(provider) + # NOTE - This is here because OpenTelemetryMiddleware excluded_urls actually expects ExcludeList and not the typical + # comma separated regex list. In the future if we upgrade OpenTelemetryMiddleware we might have to change this. + exclude_list = ExcludeList(['heartbeat', 'meta', 'openapi']) + # Enable OpenTelemetry instrumentation - app = OpenTelemetryMiddleware(app) + app = OpenTelemetryMiddleware(app, excluded_urls=exclude_list) # AioHttpClientInstrumentor().instrument()