Skip to content

Commit

Permalink
adding aiohttp back, adding more excluded_urls
Browse files Browse the repository at this point in the history
aiohttp was needed to pass trace parent id to automats
  • Loading branch information
EvanDietzMorris committed Oct 30, 2024
1 parent 2c19736 commit 760b81e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Automat/automat/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ async def __call__(self, scope, receive, send):
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
from opentelemetry.instrumentation.aiohttp_client import AioHttpClientInstrumentor

resource = Resource(attributes={
SERVICE_NAME: config.get("OTEL_SERVICE_NAME", "Automat"),
Expand All @@ -59,8 +57,8 @@ async def __call__(self, scope, receive, send):

# 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'])
exclude_list = ExcludeList(['heartbeat', 'meta', 'openapi', '^$', 'docs'])

# Enable OpenTelemetry instrumentation
app = OpenTelemetryMiddleware(app, excluded_urls=exclude_list)
# AioHttpClientInstrumentor().instrument()
AioHttpClientInstrumentor().instrument()
3 changes: 2 additions & 1 deletion Automat/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ uvicorn[standard]==0.31.0
markupsafe==2.0.1
opentelemetry-sdk==1.27.0
opentelemetry-exporter-otlp-proto-grpc==1.27.0
opentelemetry-instrumentation-asgi==0.48b0
opentelemetry-instrumentation-asgi==0.48b0
opentelemetry-instrumentation-aiohttp-client==0.48b0

0 comments on commit 760b81e

Please sign in to comment.