Skip to content

fix: [SDK-5006] shade OpenTelemetry to isolate host R8 - #2715

Draft
abdulraqeeb33 wants to merge 1 commit into
mainfrom
ar/sdk-5006-shade-otel-r8-52fe
Draft

fix: [SDK-5006] shade OpenTelemetry to isolate host R8#2715
abdulraqeeb33 wants to merge 1 commit into
mainfrom
ar/sdk-5006-shade-otel-r8-52fe

Conversation

@abdulraqeeb33

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Relocate OpenTelemetry into a OneSignal-private package so host BOMs (e.g. Embrace 1.64) cannot break R8, without shipping -dontwarn io.opentelemetry.** that would hide diagnostics for other libraries.

Details

Motivation

Host apps that also pull OpenTelemetry (Embrace 9.1.0 → OTel BOM 1.64.0) Gradle-unify with OneSignal’s transitive OTel 1.55.0 + opentelemetry-disk-buffering:1.51.0-alpha. That alpha still references ExtendedLogRecordData, which 1.64 removed, so R8 fails with a missing class.

Prior fixes added more consumer -dontwarn rules (SDK-4820, jackson, AutoValue). Those do not scale: consumer rules are merged into the host R8 config, so -dontwarn io.opentelemetry.** suppresses missing-class errors for every other library in the app.

Fixes #2714 (Linear SDK-5006).

Scope

  • :otel release AAR embeds relocated com.onesignal.shaded.opentelemetry and no longer publishes io.opentelemetry* Maven transitives.
  • Public :otel API (IOtelOpenTelemetry) no longer exposes OpenTelemetry Java types, so :core cannot compile against them.
  • Unused gRPC exporter classes are dropped from the shaded jar so we do not ship -dontwarn io.grpc.**.
  • OkHttp stays a normal shared transitive (OTLP HTTP talks to it by class name).
  • Flutter / other wrappers: no code change; they consume the Maven artifact.
  • Customer-facing OneSignal APIs (init, notifications, IAM) are unchanged.

Testing

Unit testing

  • :OneSignal:otel:checkOtelIsolation asserts the release AAR has shaded classes, no unshaded io/opentelemetry, and releaseRuntimeClasspath has no io.opentelemetry* artifacts. Wired into check and CI demo-build.
  • Existing :otel / ANR unit tests updated for the internal SDK telemetry interfaces.
  • CI minified demo: :app:assembleGmsRelease -PsimulateOtelClash forces host OTel 1.64 (the SDK-5006 regression).

Manual testing

Minified GMS demo assemble with and without -PsimulateOtelClash (R8). Device runtime of crash/log export against a host that also uses Embrace is still recommended before release.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible
    • No device in this environment; isolation check + minified R8 (including OTel 1.64 clash) cover the failure mode.

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item
Open in Web Open in Cursor 

Relocate io.opentelemetry into com.onesignal.shaded.opentelemetry and
embed it in the otel AAR so Gradle cannot unify OneSignal's 1.55 copy
with a host BOM (e.g. Embrace 1.64). Drop io.opentelemetry consumer
dontwarn rules that leaked into every library in the app.

Co-authored-by: abdulraqeeb33 <abdulraqeeb33@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff Coverage Report (Changed Lines Only)

Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff).

Changed Files Coverage

  • OtelAnrDetector.kt: 1/1 touched executable lines (100.0%) (1 touched lines in diff)
  • OtelFactory.kt: 1/2 touched executable lines (50.0%) (3 touched lines in diff)
    • 1 uncovered touched lines in this file
  • OtelLoggingHelper.kt: 1/1 touched executable lines (100.0%) (1 touched lines in diff)
  • OtelCrashReporter.kt: 1/1 touched executable lines (100.0%) (2 touched lines in diff)
  • OtelCrashUploader.kt: 1/1 touched executable lines (100.0%) (2 touched lines in diff)

Overall (aggregate gate)

5/6 touched executable lines covered (83.3% — requires ≥ 80%)

Per-file detail (informational; gate is aggregate above):

  • OtelFactory.kt: 50.0% (1 uncovered touched lines)

📥 View workflow run

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.

[Bug]: Optel clash breaks R8 again

2 participants