fix: Otel logging misc fixes#2539
Conversation
This was backwards causing ERROR to send everything
Simplified logic, cleaned up logging statements, and removed code comments that added no value.
Removed "old" format support, we never shipped that. Removed int format, we never shipped nor plan to change it. Removed "logLevel" field fallback, we will always just use "log_level"
In the context of remote logging this is "info", to the app developer this is more of a warning, however this is something we will develop later.
Looks like this was broke in a large refactor in commit 76460ee
Classes Otel depends on will be missing on Android 7 and older devices, or if the app is heavily minified. Added specific handling for this as well as an outer catch on Throwable so we at least allow any existing crash handlers to run.
We don't want logging to be the root cause of an app crash.
...nesignal/core/src/main/java/com/onesignal/core/internal/backend/impl/ParamsBackendService.kt
Outdated
Show resolved
Hide resolved
...ignal/core/src/main/java/com/onesignal/debug/internal/crash/OneSignalCrashUploaderWrapper.kt
Outdated
Show resolved
Hide resolved
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/debug/internal/logging/Logging.kt
Outdated
Show resolved
Hide resolved
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalCrashLogInit.kt
Outdated
Show resolved
Hide resolved
OneSignalSDK/onesignal/otel/src/main/java/com/onesignal/otel/crash/OtelCrashHandler.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR contains miscellaneous fixes and improvements to the OpenTelemetry (Otel) logging infrastructure in preparation for launch. The changes include a type change for process uptime tracking, crash handler refactoring for better reliability, log level adjustments, and code cleanup.
Changes:
- Changed
processUptimefrom Double (seconds) to Long (milliseconds) and updated the calculation method - Refactored crash handler to ensure the existing exception handler is always called, even if OneSignal's crash handling fails
- Adjusted several log levels from WARN to INFO to reduce noise for non-critical messages
- Added Android version checks and improved error handling for Otel-specific code
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| IOtelPlatformProvider.kt | Changed processUptime type from Double (seconds) to Long (milliseconds) |
| OtelPlatformProvider.kt | Updated processUptime calculation to use Process.getStartUptimeMillis() for accurate process uptime measurement |
| OtelCrashHandler.kt | Refactored crash handling flow to ensure existing handler is always called; added NoClassDefFoundError catch block; improved error messages |
| OneSignalCrashLogInit.kt | Code cleanup and removed verbose comments; changed log level comparison logic; adjusted logging levels |
| Logging.kt | Added Android Oreo version check before Otel logging; changed exception catch from Exception to Throwable |
| OneSignalCrashUploaderWrapper.kt | Added Android Oreo version check and error handling wrapper for crash upload |
| ParamsBackendService.kt | Simplified log level parsing to only support string format |
| OneSignalImp.kt | Changed log level from WARN to INFO for main thread blocking warning |
| InAppMessagesManager.kt | Changed log level from WARN to INFO for paused state message |
| CrashReportUploadTest.kt | Updated test output to reflect milliseconds unit for process uptime |
| OtelFieldsPerEventTest.kt | Updated test mocks to use integer values for uptime (milliseconds) |
| OtelFactoryTest.kt | Updated test mock to use integer value for uptime |
| OtelPlatformProviderTest.kt | Updated test assertions to use proper comparison matchers |
| OtelIntegrationTest.kt | Updated test assertion to use proper comparison matcher |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/internal/OneSignalCrashLogInit.kt
Show resolved
Hide resolved
...core/src/main/java/com/onesignal/debug/internal/logging/otel/android/OtelPlatformProvider.kt
Show resolved
Hide resolved
OneSignalSDK/onesignal/otel/src/main/java/com/onesignal/otel/crash/OtelCrashHandler.kt
Outdated
Show resolved
Hide resolved
| override fun start() { | ||
| // Otel library requires Android Oreo (8) or newer | ||
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return | ||
| if (AndroidUtils.androidSDKInt < Build.VERSION_CODES.O) return |
There was a problem hiding this comment.
What i meant was, you could have a AndroidLoggingUtils or something similar and that class basically has something like
boolean fn isOtelLoggingSupport()
and that does this check if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
Addresses review feedback to consolidate the scattered Build.VERSION.SDK_INT < Build.VERSION_CODES.O checks into a single OtelSdkSupport utility object. - OtelSdkSupport.isSupported replaces inline version checks in Logging, OneSignalCrashUploaderWrapper, and OneSignalCrashHandlerFactory - Factory now uses require() instead of returning a NoOpCrashHandler - OtelSdkSupport.isSupported is writable for unit tests - Removed Logging.androidVersion field (replaced by OtelSdkSupport) - Updated all affected tests Co-authored-by: Cursor <cursoragent@cursor.com>
- CrashReportUploadTest.kt: kept our version (new test for processUptime fix) - OneSignalCrashHandlerFactoryTest.kt: merged base's additional tests with OtelSdkSupport usage - OtelFieldsPerEventTest.kt: kept base's setupDefaultMocks helper with Long processUptime type Co-authored-by: Cursor <cursoragent@cursor.com>
Deleted in base branch by cleanup PR #2541. Co-authored-by: Cursor <cursoragent@cursor.com>
|
moved these changes into the above PR |
Description
One Line Summary
Misc fixes and clean up for the otel branch.
Details
Commits are atomic, recommend reviewer look them over in time order.
Motivation
Fixes required for launch
Scope
Only affect logging logic
Testing
Unit testing
Updated unit tests
Manual testing
Tested on Android 5, 6, and 14 emulators.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is