open-telemetry / opentelemetry-python-contrib

OpenTelemetry instrumentation for Python modules
https://opentelemetry.io
Apache License 2.0
701 stars 584 forks source link

Adding addition middleware in FastAPI with FastAPIInstrumentor is creating a strange span. #2695

Open horw opened 2 months ago

horw commented 2 months ago

I have added a simple middleware in FastAPI and this has created a strange span, which you can see in the image. image

I have used the following middleware.

@app.middleware("http")
async def hello(request: Request, call_next):
    resp = await call_next(request)
    return resp

How can I create middleware that will not create a new span? Or at least without warning clock skew adjustment disabled; not applying calculated delta of -5.163065ms ?

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/60fb936b7e5371b3e5587074906c49fb873cbd76/instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py#L198

xrmx commented 2 months ago

Why is this strange? If this for the multiple spans on POST handling I think we already have an issue for that.