apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.87k stars 719 forks source link

Tracing & Instrumentation Support #2537

Open Mordil opened 2 years ago

Mordil commented 2 years ago

Feature request

Integration with Swift ecosystem libraries to support network layer tracing & instrumentation with SwiftLog and SwiftTracing

At the very least supporting the Baggage common currency from InstrumentationBaggage

Motivation

At Peek, we are looking to gain deep insights into the entire stack of our iOS applications and are looking to add full end-to-end tracing of our product.

As part of this, we'd like to be able to isolate our cache reading & writing, from our network requests, to our UI logic.

To be able to do this using SwiftTracing, we'd need some way to pass our dynamic Baggage context into our ApolloInterceptor types, but the entire Apollo framework of types don't understand this concept.

If ApolloInterceptor was fully async/await capable, we wouldn't need deep integration with the package at the Apollo layer, as we'd be able to leverage Task Local Values in our ApolloInterceptor types.

However, we'd still lose out on Apollo being able to provide trace spans and logs that provide our application with richer data for debugging issues.

Proposed solution

Pull in the common API packages and extend protocol definitions to receive Logger and Baggage instances for logging & tracing purposes

calvincestari commented 2 years ago

Good ideas @Mordil. We can certainly take this into consideration for the scope of work coming up next in preparation for 2.0.