Skip to content

Adding request-based tags to url session spans #1649

@SebastianOsinski

Description

@SebastianOsinski

Is your feature request related to a problem? Please describe.

Use case: I would like the span to include additional tag with GraphQL operation name in it.

Right now, when using built-in URLSessionInstrumentation, it is only possible to add static tags to all requests by configuring tags property when enabling tracing. I would like to add tags with dynamic values, depending on what request is being made.
Currently there is no way to access the span created by TracingURLSessionHandler

On Android it is possible to do this by using TracedRequestListener

Screenshot 2024-01-26 at 11 20 19

Describe the solution you'd like

A possibility to define listeners/callbacks for URLSessionInstrumentation which would allow editing the span based on the request. Similar to the Android solution

Describe alternatives you've considered

I thought I could achieve it by accessing Tracer.shared().activeSpan in my implementation of DatadogURLSessionHandler but it is not populated. I also tried to somehow create a span with trace id and span id from URLSessionTaskInterception received in my implementation of DatadogURLSessionHandler but I don't see a way of doing that.

Additional context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions