Skip to content

Expose trace as api dependency in okhttp module#3366

Merged
kikoveiga merged 2 commits into
developfrom
kikoveiga/add-trace-api-to-okhttp-build-gradle
Apr 15, 2026
Merged

Expose trace as api dependency in okhttp module#3366
kikoveiga merged 2 commits into
developfrom
kikoveiga/add-trace-api-to-okhttp-build-gradle

Conversation

@kikoveiga
Copy link
Copy Markdown
Contributor

@kikoveiga kikoveiga commented Apr 10, 2026

What does this PR do?

Exposes dd-sdk-android-trace as an api dependency of dd-sdk-android-okhttp, fixing the following Kotlin compiler warning in consumer modules that don't independently depend on dd-sdk-android-trace (namely dd-sdk android-glide and sample/tv):

Cannot access class 'DatadogSpan' in the expression type. This may be forbidden soon.
Check the module classpath for missing or conflicting dependencies.

The warning is triggered when calling TracingInterceptor.BaseBuilder#setTraceSampler(Sampler<DatadogSpan>), since DatadogSpan (from trace-api) was only reachable transitively through implementation(dd-sdk-android-trace), which Gradle hides from consumers' compile classpath.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@kikoveiga kikoveiga requested review from a team as code owners April 10, 2026 15:53
@kikoveiga kikoveiga self-assigned this Apr 10, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.83%. Comparing base (06f7f75) to head (e9f1a7a).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3366      +/-   ##
===========================================
+ Coverage    71.81%   71.83%   +0.02%     
===========================================
  Files          948      948              
  Lines        34952    34952              
  Branches      5804     5804              
===========================================
+ Hits         25100    25106       +6     
+ Misses        8257     8248       -9     
- Partials      1595     1598       +3     

see 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@0xnm
Copy link
Copy Markdown
Member

0xnm commented Apr 10, 2026

We have one more problem of that kind: setTraceContextInjection is using the symbol which is declared in dd-sdk-android-trace.

fun setTraceContextInjection(traceContextInjection: TraceContextInjection): R {

it is declared here

https://github.com/DataDog/dd-sdk-android/blob/d19a14a0bb1f24a0f5a6f7827952d176a50e602c/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/TraceContextInjection.kt

I'm wondering if we can move it to the -api module, but then it will be a breaking API change 🤔

@satween wdyt?

@satween
Copy link
Copy Markdown
Contributor

satween commented Apr 14, 2026

We have one more problem of that kind: setTraceContextInjection is using the symbol which is declared in dd-sdk-android-trace.

fun setTraceContextInjection(traceContextInjection: TraceContextInjection): R {

it is declared here

https://github.com/DataDog/dd-sdk-android/blob/d19a14a0bb1f24a0f5a6f7827952d176a50e602c/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/TraceContextInjection.kt

I'm wondering if we can move it to the -api module, but then it will be a breaking API change 🤔

@satween wdyt?

We discussed with @0xnm in person, and it's seems like the best solution for now is the following:

  • replace api("-trace-api") with api("-trace") till the next major release.
  • add a JIRA ticket linked to v4 scope, that states that TraceContextInjection.kt has to be moved into -trace-api module and api("-trace") should be replaced with api("-trace-api").
  • Add TODO comment to that ticket

@kikoveiga kikoveiga force-pushed the kikoveiga/add-trace-api-to-okhttp-build-gradle branch from 3e9c425 to e9f1a7a Compare April 15, 2026 10:12
@kikoveiga kikoveiga requested review from 0xnm and satween April 15, 2026 10:12
@kikoveiga
Copy link
Copy Markdown
Contributor Author

kikoveiga commented Apr 15, 2026

Thank you @satween and @0xnm, created the ticket and added as TODO note in the code.

@kikoveiga kikoveiga merged commit a811d48 into develop Apr 15, 2026
27 checks passed
@kikoveiga kikoveiga deleted the kikoveiga/add-trace-api-to-okhttp-build-gradle branch April 15, 2026 11:05
@kikoveiga kikoveiga changed the title Expose trace-api as api dependency in okhttp module Expose trace as api dependency in okhttp module Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants