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

Ktor Client 3.0 Support #131

Open
sausti opened this issue Dec 30, 2024 · 4 comments
Open

Ktor Client 3.0 Support #131

sausti opened this issue Dec 30, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@sausti
Copy link

sausti commented Dec 30, 2024

Feature description

  1. Our multiplatform app uses Ktor Client to make network requests. We've integrated with Datadog's SDK instrumentation for Ktor.
  2. Datadog's SDK implementation only supports Ktor 2.0 and not the recently released Ktor 3.0. We are unable to update our Ktor Client to version 3.0 because of this.
  3. We'd like to see support for the Ktor 3.0 client.

Proposed solution

Update the Ktor dependency to 3.0.*+, or create a separate dedicated library for Ktor 3.0.

Other relevant information

No response

@sausti sausti added the enhancement New feature or request label Dec 30, 2024
@0xnm
Copy link
Member

0xnm commented Dec 31, 2024

Hello @sausti!

Thanks for reporting it. We will estimate the changes needed and add the necessary support.

@0xnm
Copy link
Member

0xnm commented Jan 2, 2025

Hi @sausti! Can you please post the error you have?

By looking on the migration guide I can see that only binary-incompatible change for the Ktor Client is the rename of the HttpRespose#content property, which our instrumentation is not using.

At least I'm able to compile and run our instrumentation with Ktor 3.x without any changes.

@sausti
Copy link
Author

sausti commented Jan 2, 2025

Thank you for the help @0xnm! Android compiles and runs as expected when targeting Ktor 3.0.3, but on iOS, we see the following:

Uncaught Kotlin exception: kotlin.native.internal.IrLinkageError: Constructor 'AttributeKey.<init>' can not be called: No constructor found for symbol 'io.ktor.util/AttributeKey.<init>|<init>(kotlin.String){}[0]'
    at 0   App.debug.dylib                   0x10bdcaaa7        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 99 
    at 1   App.debug.dylib                   0x10bdc483b        kfun:kotlin.Error#<init>(kotlin.String?){} + 95 
    at 2   App.debug.dylib                   0x10bdfe9eb        kfun:kotlin.native.internal.IrLinkageError#<init>(kotlin.String?){} + 95 
    at 3   App.debug.dylib                   0x10bdfeaa3        kfun:kotlin.native.internal#ThrowIrLinkageError(kotlin.String?){}kotlin.Nothing + 163 
    at 4   App.debug.dylib                   0x10d99b327        kfun:com.datadog.kmp.ktor.internal.plugin.DatadogKtorPlugin.Companion.<init>#internal + 115 
    at 5   App.debug.dylib                   0x10d999163        kfun:com.datadog.kmp.ktor.internal.plugin.DatadogKtorPlugin.$init_global#internal + 131 
    at 6   App.debug.dylib                   0x10bf88be3        CallInitGlobalPossiblyLock + 563 
    at 7   App.debug.dylib                   0x10d999273        kfun:com.datadog.kmp.ktor.internal.plugin.DatadogKtorPlugin#<init>(com.datadog.kmp.rum.RumMonitor;kotlin.collections.Map<kotlin.String,kotlin.collections.Set<com.datadog.kmp.ktor.TracingHeaderType>>;com.datadog.kmp.ktor.sampling.Sampler;com.datadog.kmp.ktor.internal.trace.TraceIdGenerator;com.datadog.kmp.ktor.internal.trace.SpanIdGenerator;com.datadog.kmp.ktor.RumResourceAttributesProvider){} + 219 
    at 8   App.debug.dylib                   0x10d99739b        kfun:com.datadog.kmp.ktor#datadogKtorPlugin(kotlin.collections.Map<kotlin.String,kotlin.collections.Set<com.datadog.kmp.ktor.TracingHeaderType>>;kotlin.Float;com.datadog.kmp.ktor.RumResourceAttributesProvider){}io.ktor.client.plugins.api.ClientPlugin<kotlin.Unit> + 523 
    at 9   App.debug.dylib                   0x10d99757f        kfun:com.datadog.kmp.ktor#datadogKtorPlugin$default(kotlin.collections.Map<kotlin.String,kotlin.collections.Set<com.datadog.kmp.ktor.TracingHeaderType>>?;kotlin.Float;com.datadog.kmp.ktor.RumResourceAttributesProvider?;kotlin.Int){}io.ktor.client.plugins.api.ClientPlugin<kotlin.Unit> + 391 
...

Which is odd, as AttributeKey's (Use in Datadog) signature has not changed from Ktor 2 to Ktor 3? Perhaps this is due to a different linking error caused by mismatched versions on iOS?

@0xnm
Copy link
Member

0xnm commented Jan 2, 2025

It is inline function and actually under the hood the captured type definition changed in the Ktor 3.x release.

I'm wondering though if it is possible to solve this issue completely on the client side, by leveraging linking flags, will check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants