-
Notifications
You must be signed in to change notification settings - Fork 376
WIP - Feat: OpenTelemetry crash reporting #2405
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
base: main
Are you sure you want to change the base?
Conversation
Adding disk-buffering to otel logging required bumping to Kotlin 2.2. Adding the code to implement this in a follow up commit.
When the app is started again we send any pending crash reports.
Also refactored crash handle classes into their own namespace. Refactored IOneSignalOpenTelemetry properties into suspend functions, as some values we want to add to all Otel requests were suspend.
Also made all otel types internal and a few other misc cleanup.
We need to start it sooner to catch crashes in things like other IStartableService's.
Models can throw if something goes wrong initializing them.
21d4198 to
a61e2bc
Compare
| @@ -0,0 +1,5 @@ | |||
| package com.onesignal.debug.internal.crash | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we place all the logging related code in its own module, just in case we go in the direction of KMP, it will be extremely easy to build an artifact out this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make this a new module, that core depends on. We can switch the module to KMP later.
...SDK/onesignal/core/src/main/java/com/onesignal/debug/internal/crash/OneSignalCrashHandler.kt
Show resolved
Hide resolved
| } | ||
|
|
||
| object HttpRecordBatchExporter { | ||
| @RequiresApi(Build.VERSION_CODES.O) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minSdk supported as of now is 21. What would happen when this method gets called on a App that is between 21 and 26 (version_code.0)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to test and most likely need to handle this.
...core/src/main/java/com/onesignal/debug/internal/logging/otel/crash/OneSignalCrashUploader.kt
Show resolved
Hide resolved
| mapOf( | ||
| "X-OneSignal-App-Id" to appId, | ||
| HTTP_SDK_VERSION_HEADER_KEY to HTTP_SDK_VERSION_HEADER_VALUE, | ||
| "x-honeycomb-team" to "", // TODO: REMOVE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we remove this?
| import java.io.File | ||
|
|
||
| internal class OneSignalCrashConfigProvider( | ||
| private val _applicationService: IApplicationService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be able to pass the the path directly here instead of depending on our SDK class
| .put("$OS_OTEL_NAMESPACE.exception.thread.name", thread.name) | ||
| .build() | ||
|
|
||
| _openTelemetry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we sure that this is ready with all the relevant fields populated into itself?
|
|
||
| override suspend fun forceFlush(): CompletableResultCode { | ||
| val sdkLoggerProvider = getSdk().sdkLoggerProvider | ||
| return suspendCoroutine { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work while the app is being closed down by the OS? Does it have to run on the main thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check that suspendCoroutine isn't making a new thread.
| _osPerEventFields: OneSignalOtelFieldsPerEvent, | ||
| ) : OneSignalOpenTelemetryBase(_osTopLevelFields, _osPerEventFields), | ||
| IOneSignalOpenTelemetryRemote { | ||
| private val appId: String get() = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this lazy so that it fetches on time and then stores it in the memory?
| } | ||
| } | ||
|
|
||
| implementation platform("io.opentelemetry:opentelemetry-bom:1.55.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we create variables for the versions numbers used here instead of hardcoding them here?
Description
One Line Summary
Add OpenTelemetry libraries to report crashes to improve SDK reliability.
Details
Motivation
Allows us to quickly identify and fix issues caused by this SDK.
Scope
Only adds OpenTelemetry to track crashes.
Testing
Unit testing
TODO: Need to add unit testing yet.
Manual testing
Tested on an Android 14 Emulator:
Tested has only been done with a known working Otel backend, HoneyComb, until we
have our own backend to receive the payload.
Remaning Tasks
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is