Skip to content

ASGI TraceMiddleware does not process response headers #4443

@ghost

Description

Summary of problem

When using ASGI TraceMiddleware the response headers are not processed into a trace.

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

1.5.3 but the same problem is in previous versions

How can we reproduce your problem?

  • Setup a minimal ASGI application using TraceMiddleware that is responding with known a header
  • add this header to the ddtrace.config.trace_headers()
  • produce a trace

Produced trace has only request headers (http.request.headers.*) but no response header (http.response.headers.*).

Probable cause

I did a little digging up and found that code is using response headers directly from ASGI http.response.start message (see code). However those headers are not strings but bytes so they are not picked up ("the-header" != b"the-header"). This part requires the same treatment as request headers (see code).

I will try to create PR for it if you don't mind.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions