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

Click Instrumentation Bypass Issue

Open
#3,846 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe your environment

OS: Fedora 42
Python version: 3.12
Package version: 0.57b0

What happened?

I was running a FastAPI application using python -m uvicorn instead of using the uvicorn executable directly and was seeing all of my requests going under a top-level python -m uvicorn span.

Steps to Reproduce

Attempt to run a FastAPI application using python -m uvicorn instead of uvicorn.

Expected Result

Each separate request should get it's own span instead of every request's span going under a top-level span.

Actual Result

Each separate request's span goes under a single top-level span when starting with python -m uvicorn

Additional context

I did some pre-emptive looking into this problem and have found that it is caused by the click Instrumentation failing to sniff out that it is being ran in a FastAPI application.

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

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

Reproduce the issue by starting the FastAPI application with python -m uvicorn and compare it with the uvicorn executable. Inspect the Click instrumentation's FastAPI detection and add a regression test if the repository provides one; done means each request has its own span rather than being nested under one top-level span.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.