Skip to content

Commit

Permalink
Adding middleware is already done in the fastapi instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Nov 17, 2023
1 parent 7982372 commit eb6192c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/diracx/routers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def instrument_otel(app: ASGIApp, app_name: str, log_correlation: bool = True) -

# set the tracer provider
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider)

# elif MODE == "otel-collector-http":
# tracer.add_span_processor(
Expand All @@ -85,6 +84,7 @@ def instrument_otel(app: ASGIApp, app_name: str, log_correlation: bool = True) -
OTLPSpanExporterGRPC(endpoint=OTEL_GRPC_ENDPOINT, insecure=True)
)
)
trace.set_tracer_provider(tracer_provider)

# metric_reader = PeriodicExportingMetricReader(ConsoleMetricExporter(),export_interval_millis=1000)
metric_reader = PeriodicExportingMetricReader(
Expand All @@ -105,16 +105,13 @@ def instrument_otel(app: ASGIApp, app_name: str, log_correlation: bool = True) -
for hl in logger.handlers:
hl.setFormatter(logging.Formatter(DEFAULT_LOGGING_FORMAT))

Check warning on line 106 in src/diracx/routers/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/diracx/routers/__init__.py#L106

Added line #L106 was not covered by tests

# FastAPIInstrumentor.instrument_app(
# app, tracer_provider=tracer_provider, meter_provider=meter_provider
# )

FastAPIInstrumentor.instrument_app(
app, tracer_provider=tracer_provider, meter_provider=meter_provider
)
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

app.add_middleware(
OpenTelemetryMiddleware,
tracer_provider=tracer_provider,
meter_provider=meter_provider,
)


# Rules:
Expand Down

0 comments on commit eb6192c

Please sign in to comment.