-
-
Notifications
You must be signed in to change notification settings - Fork 32
automatic breadcrumbs for app, activity and sessions lifecycles and system events #348
Conversation
@marandaneto Did you take into account that if android build has been obfuscated (e.g. with ProGuard or DexGuard), activity names in the breadcrumb messages will look like gibberish and won't be retraced? Also, is there a way to disable the integration once this is merged? |
we are gonna probably extract this module as a new maven package (android aar) and ship it with a proguard rule for that, keeping Activity names. not sure if we are gonna demangle the breadcrumbs as well, I'll check this internally. |
It would be nice if you could demangle the class names in the breadcrumbs as a general feature. Putting a rule for keeping activity names could be a nasty surprise for some people though. In my opinion it will be better as an opt-in feature, so having it as a separate artifact makes sense indeed. |
yes, I agree, as I said, it's gonna be a separated maven package, so generally opt-in, I'll update you on that, thanks for the tip. |
sentry-android-core/src/main/java/io/sentry/android/core/ActivityBreadcrumbsIntegration.java
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #348 +/- ##
============================================
- Coverage 58.89% 58.84% -0.05%
Complexity 758 758
============================================
Files 87 87
Lines 3540 3543 +3
Branches 341 341
============================================
Hits 2085 2085
- Misses 1302 1305 +3
Partials 153 153
Continue to review full report at Codecov.
|
sentry-android-core/src/main/java/io/sentry/android/core/DefaultAndroidEventProcessor.java
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java
Outdated
Show resolved
Hide resolved
// TODO: should we log the params? sometimes its necessary eg | ||
// ACTION_AIRPLANE_MODE_CHANGED | ||
// its a single action with 2 states that differs on extras | ||
final Bundle extras = intent.getExtras(); | ||
final Map<String, String> newExtras = new HashMap<>(); | ||
if (extras != null && !extras.isEmpty()) { | ||
for (String item : extras.keySet()) { | ||
try { | ||
newExtras.put(item, extras.get(item).toString()); | ||
} catch (Exception ignored) { | ||
} | ||
} | ||
} | ||
breadcrumb.setData("extras", newExtras); |
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.
this is trick, each broadcast has its own extras, we could send them all as I do now, but there are a lot of garbage too.
the other way would be to only send the useful extras for each broadcast.
the thing is, docs for extras are not great and it'd take some time to find the right keys.
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.
Let's leave it as you did and see the feedback. If we only add stuff manually we could be missing things and there's the extra work/maintenance
...y-android-core/src/main/java/io/sentry/android/core/AppComponentsBreadcrumbsIntegration.java
Outdated
Show resolved
Hide resolved
so it seems that |
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 left suggestions and some nits -> !
...y-android-core/src/main/java/io/sentry/android/core/AppComponentsBreadcrumbsIntegration.java
Outdated
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/AppLifecycleIntegration.java
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/AppLifecycleIntegration.java
Outdated
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/LifecycleWatcher.java
Outdated
Show resolved
Hide resolved
addSessionBreadcrumb("end"); | ||
hub.endSession(); |
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 could pass here the session duration:
addSessionBreadcrumb("end"); | |
hub.endSession(); | |
hub.endSession(); | |
addSessionBreadcrumb("end", hub.getDuration()); |
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.
there's no API for that right now, but yeah we could enrich these breadcrumbs later on
...ry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java
Show resolved
Hide resolved
...ry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java
Outdated
Show resolved
Hide resolved
// TODO: should we log the params? sometimes its necessary eg | ||
// ACTION_AIRPLANE_MODE_CHANGED | ||
// its a single action with 2 states that differs on extras | ||
final Bundle extras = intent.getExtras(); | ||
final Map<String, String> newExtras = new HashMap<>(); | ||
if (extras != null && !extras.isEmpty()) { | ||
for (String item : extras.keySet()) { | ||
try { | ||
newExtras.put(item, extras.get(item).toString()); | ||
} catch (Exception ignored) { | ||
} | ||
} | ||
} | ||
breadcrumb.setData("extras", newExtras); |
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.
Let's leave it as you did and see the feedback. If we only add stuff manually we could be missing things and there's the extra work/maintenance
sentry-android-core/src/main/java/io/sentry/android/core/TempSensorBreadcrumbsIntegration.java
Outdated
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/TempSensorBreadcrumbsIntegration.java
Outdated
Show resolved
Hide resolved
AFAIK Activity names are kept if they are found in the AndroidManifest.xml file (AAPT generates rules for this in |
yes,
can confirm, I was suspecting because of either |
📢 Type of change
📜 Description
automatic breadcrumbs for app, activity and sessions lifecycles and system events
💡 Motivation and Context
we'd like to collect automatic breadcrumbs
fixes #210
💚 How did you test it?
📝 Checklist
🔮 Next steps