Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding request-based tags to url session spans #1649

Open
SebastianOsinski opened this issue Jan 26, 2024 · 4 comments
Open

Adding request-based tags to url session spans #1649

SebastianOsinski opened this issue Jan 26, 2024 · 4 comments

Comments

@SebastianOsinski
Copy link

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.

@SebastianOsinski SebastianOsinski changed the title Adding request-based tags to Adding request-based tags to url session spans Jan 26, 2024
@ganeshnj
Copy link
Contributor

Indeed iOS SDK doesn't have similar feature to intercept the span created by the instrumentation.

We can provide something similar here in the form of either delegate or a closure. You can pass this as part of URLSessionInstrumentation.Configuration. Hence, you can callback per enable URLSessionInstrumentation call.

@SebastianOsinski
Copy link
Author

@ganeshnj that sounds perfect. Thank you for such swift response!

@ElonPark
Copy link

ElonPark commented Apr 16, 2024

I have the same needs as the current issue

We can provide something similar here in the form of either delegate or a closure. You can pass this as part of
URLSessionInstrumentation.Configuration. Hence, you can callback per enable URLSessionInstrumentation call.

@ganeshnj Can you provide sample code for the method you suggested in your answer?

@ganeshnj
Copy link
Contributor

Like I said, we don't have such capability as of now in the iOS SDK but something we can provide in future.

Thanks for upvoting, it helps us prioritize the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants