-
Notifications
You must be signed in to change notification settings - Fork 375
fix: Otel logging misc fixes #2539
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
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7d68d83
fix: inverse LogLevel logic for omitting
jkasten2 a9b833e
chore: clean up initializeOtelLogging
jkasten2 f400646
chore: clean up parseLogLevel
jkasten2 9a8954d
fix: lower severity of main thread log
jkasten2 8f9c305
fix: processUptime
jkasten2 05ca3c4
fix: account for otel missing class
jkasten2 1bf6a25
fix: crash on otel usage on Android 7 and older
jkasten2 3c604c5
fix: catch Throwable on otel access
jkasten2 e41a735
fix: lower severity of IAM paused log
jkasten2 2656318
fix: address Build.VERSION usage and tests
jkasten2 b377734
fix: default logging to NONE on parse error
jkasten2 f8e7b4a
fix: address log entries
jkasten2 dd14a15
fix: return NONE on paring error
jkasten2 1b121ef
fix: centralize SDK version check into OtelSdkSupport
9305e7d
fix: resolve merge conflicts with ar-otel-crash-reporting
134a91c
chore: remove CrashReportUploadTest
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 7 additions & 20 deletions
27
...nal/core/src/main/java/com/onesignal/debug/internal/crash/OneSignalCrashHandlerFactory.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,38 @@ | ||
| package com.onesignal.debug.internal.crash | ||
|
|
||
| import android.content.Context | ||
| import android.os.Build | ||
| import com.onesignal.debug.internal.logging.Logging | ||
| import com.onesignal.debug.internal.logging.otel.android.createAndroidOtelPlatformProvider | ||
| import com.onesignal.otel.IOtelCrashHandler | ||
| import com.onesignal.otel.IOtelLogger | ||
| import com.onesignal.otel.OtelFactory | ||
|
|
||
| /** | ||
| * Factory for creating crash handlers with SDK version checks. | ||
| * For SDK < 26, returns a no-op implementation. | ||
| * For SDK >= 26, returns the Otel-based crash handler. | ||
| * Factory for creating Otel-based crash handlers. | ||
| * Callers must verify [OtelSdkSupport.isSupported] before calling [createCrashHandler]. | ||
| * | ||
| * Uses minimal dependencies - only Context and logger. | ||
| * Platform provider uses OtelIdResolver internally which reads from SharedPreferences. | ||
| */ | ||
| internal object OneSignalCrashHandlerFactory { | ||
| /** | ||
| * Creates a crash handler appropriate for the current SDK version. | ||
| * Creates the Otel crash handler. | ||
| * This should be called as early as possible, before any other initialization. | ||
| * | ||
| * @param context Android context for creating platform provider | ||
| * @param logger Logger instance (can be shared with other components) | ||
| * @throws IllegalArgumentException if called on an unsupported SDK | ||
| */ | ||
| fun createCrashHandler( | ||
| context: Context, | ||
| logger: IOtelLogger, | ||
| ): IOtelCrashHandler { | ||
| // Otel requires SDK 26+, use no-op for older versions | ||
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { | ||
| Logging.info("OneSignal: Creating no-op crash handler (SDK ${Build.VERSION.SDK_INT} < 26)") | ||
| return NoOpCrashHandler() | ||
| require(OtelSdkSupport.isSupported) { | ||
| "createCrashHandler called on unsupported SDK (< ${OtelSdkSupport.MIN_SDK_VERSION})" | ||
| } | ||
|
|
||
| Logging.info("OneSignal: Creating Otel crash handler (SDK ${Build.VERSION.SDK_INT} >= 26)") | ||
| // Create platform provider - uses OtelIdResolver internally | ||
| Logging.info("OneSignal: Creating Otel crash handler (SDK >= ${OtelSdkSupport.MIN_SDK_VERSION})") | ||
| val platformProvider = createAndroidOtelPlatformProvider(context) | ||
| return OtelFactory.createCrashHandler(platformProvider, logger) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * No-op crash handler for SDK < 26. | ||
| */ | ||
| private class NoOpCrashHandler : IOtelCrashHandler { | ||
| override fun initialize() { | ||
| Logging.info("OneSignal: No-op crash handler initialized (SDK < 26, Otel not supported)") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...gnalSDK/onesignal/core/src/main/java/com/onesignal/debug/internal/crash/OtelSdkSupport.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.onesignal.debug.internal.crash | ||
|
|
||
| import android.os.Build | ||
|
|
||
| /** | ||
| * Centralizes the SDK version requirement for Otel-based features | ||
| * (crash reporting, ANR detection, remote log shipping). | ||
| * | ||
| * [isSupported] is writable internally so that unit tests can override | ||
| * the device-level gate without Robolectric @Config gymnastics. | ||
| */ | ||
| internal object OtelSdkSupport { | ||
| /** Otel libraries require Android O (API 26) or above. */ | ||
| const val MIN_SDK_VERSION = Build.VERSION_CODES.O // 26 | ||
|
|
||
| /** | ||
| * Whether the current device meets the minimum SDK requirement. | ||
| * Production code should treat this as read-only; tests may flip it via [reset]/direct set. | ||
| */ | ||
| var isSupported: Boolean = Build.VERSION.SDK_INT >= MIN_SDK_VERSION | ||
| internal set | ||
|
|
||
| /** Restores the runtime-detected value — call in test teardown. */ | ||
| fun reset() { | ||
| isSupported = Build.VERSION.SDK_INT >= MIN_SDK_VERSION | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.