Skip to content
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

Add session properties to native crashes from the associated session #1744

Merged
merged 4 commits into from
Dec 9, 2024

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Dec 4, 2024

Goal

Use appState and session properties from associated session when sending native crashes. Prior to this, metadata from the current session was being used erroneously. Now, we will grab this from the session that is associated with the crash that will be resurrected.

In a later PR, the code will be modified to take from the cached payload envelope if a session doesn't exist.

Copy link
Contributor

github-actions bot commented Dec 4, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 88.33333% with 7 lines in your changes missing coverage. Please review.

Project coverage is 85.28%. Comparing base (f3c3d7f) to head (8f57ff9).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...nal/resurrection/PayloadResurrectionServiceImpl.kt 90.19% 1 Missing and 4 partials ⚠️
...android/embracesdk/internal/payload/EnvelopeExt.kt 0.00% 0 Missing and 1 partial ⚠️
...oid/embracesdk/internal/spans/EmbraceExtensions.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1744      +/-   ##
==========================================
- Coverage   85.31%   85.28%   -0.04%     
==========================================
  Files         464      464              
  Lines       10775    10793      +18     
  Branches     1591     1596       +5     
==========================================
+ Hits         9193     9205      +12     
- Misses        870      871       +1     
- Partials      712      717       +5     
Files with missing lines Coverage Δ
...acesdk/internal/arch/schema/EmbraceAttributeExt.kt 100.00% <100.00%> (ø)
...esdk/internal/injection/NativeFeatureModuleImpl.kt 100.00% <ø> (ø)
...bracesdk/internal/ndk/NativeCrashDataSourceImpl.kt 98.00% <100.00%> (+0.08%) ⬆️
...android/embracesdk/internal/payload/EnvelopeExt.kt 25.00% <0.00%> (-8.34%) ⬇️
...oid/embracesdk/internal/spans/EmbraceExtensions.kt 75.75% <0.00%> (-2.37%) ⬇️
...nal/resurrection/PayloadResurrectionServiceImpl.kt 85.05% <90.19%> (-2.62%) ⬇️

@bidetofevil bidetofevil force-pushed the hho/native-crash-metadata branch from caf4088 to fa88417 Compare December 7, 2024 00:40
@bidetofevil bidetofevil marked this pull request as ready for review December 7, 2024 01:15
@bidetofevil bidetofevil requested a review from a team as a code owner December 7, 2024 01:15
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +79 to +80
fun Span.getSessionProperties(): Map<String, String> =
attributes?.filter { it.key != null && it.data != null }?.associate { it.key to it.data } as Map<String, String>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see anywhere this function was used in review & am not sure of its purpose. It seems like either the name or functionality is wrong as the session properties don't live exclusively on a span's attributes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might've been looking at an older version? I added usage after the first commit - in line 75 of PayloadResurrectionServiceImpl.kt

crashAttributes.setAttribute(
key = embCrashNumber,
value = nativeCrashNumber.toString(),
keepBlankishValues = false,
)

// nativeCrash.appState?.let { appState ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did so in an subsequent commit

inputStream = GZIPInputStream(cacheStorageService.loadPayloadAsStream(this)),
type = envelopeType.serializedType
)
private fun processUndeliveredPayload(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is fairly long with lots of indentation & that makes it hard to read IMO. I'd suggest breaking it into 2-3 smaller functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Good call.

@bidetofevil bidetofevil force-pushed the hho/native-crash-metadata branch from 179c62c to 8f57ff9 Compare December 9, 2024 19:28
@bidetofevil bidetofevil merged commit ac235c4 into main Dec 9, 2024
8 checks passed
Copy link
Collaborator Author

Merge activity

  • Dec 9, 2:40 PM EST: A user merged this pull request with Graphite.

@bidetofevil bidetofevil deleted the hho/native-crash-metadata branch December 9, 2024 19:40
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.

2 participants