open-telemetry / open-telemetry/opentelemetry-python-contrib

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

Open
#2,695 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/init.py around line 198, then reproduce the reported middleware in a minimal FastAPI application. Compare the generated spans and clock-skew warning with and without the middleware; completion requires identifying whether the behavior is an instrumentation bug or documenting the supported way to avoid it.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.