Skip to content

Can't get trace or span ID in ASGI style middleware with FastAPI for request log #6030

@mattupstate

Description

@mattupstate

Summary of problem

Which version of dd-trace-py are you using?

1.14.0

Which version of pip are you using?

N/A

Which libraries and their versions are you using?

python = "^3.10"
fastapi = "^0.96.0"
ddtrace = "^1.14.0"
structlog = "^23.1.0"
uvicorn = "^0.22.0"
asgiref = "^3.7.2"

How can we reproduce your problem?

Take a look at this gist: https://gist.github.com/mattupstate/eee68a5ac531b82e0cf18b45816330c5
What's very unusual is that the trace and span ID are non-zero when adding an arbitrary middleware using FastAPI's app.middleware decorator. I wonder if this is at all related to #4397

What is the result that you get?

Trace and span ID values equal to 0 when using ASGI spec style middleware to produce a request log.

What is the result that you expected?

Trace and span ID values to be non-zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions