Skip to content

Conversation

@LikeTheSalad
Copy link
Contributor

Summary

We need a way to decode Android crash's stacktraces so that they can provide meaningful insights to our customers, this is because, due to security reasons, android apps tend to obfuscate their code before publishing it online, making crash reports contain obfuscated names, which don't make any sense before mapping them to the actual source code names.

In order to help our customers deobfuscate their stacktraces, we need to allow them to provide us with an R8 map file, which is generated by the code obfuscation tool (R8) at compile time. This map file is needed to later do the deobfuscation process.

So these code changes take care of adding a new endpoint that our customers can use to upload their map files, similarly to what's currently available to RUM Sourcemaps, the Android map files will be uploaded to ES, using the same index as the one currently used to store RUM Sourcemaps.

There's a couple of reasons why a new endpoint to upload android maps is needed instead of re-using the existing RUM Sourcemaps one:

  • The Sourcemaps upload endpoint has validations in place to check the sourcemap format, which must be a JSON with some expected keys available. Android map files don't have a JSON format, so they are rejected by the sourcemaps endpoint.
  • Android map files tend to be large in size, just as an example, the map file generated for our sample app has a size of ~7 MB, so for real apps this number can be larger, which would also cause issues with the RUM upload endpoint since it has a max file limit size of 1 MB.
  • The RUM upload endpoint contains a parameter (bundle_filepath ) that doesn't have an equivalent for the android map use case.

This PR depends on #161152

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@ghost
Copy link

ghost commented Jul 5, 2023

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@LikeTheSalad LikeTheSalad marked this pull request as ready for review July 6, 2023 09:33
@LikeTheSalad LikeTheSalad requested a review from a team as a code owner July 6, 2023 09:33
@LikeTheSalad
Copy link
Contributor Author

@elasticmachine merge upstream

@botelastic botelastic bot added the Team:APM - DEPRECATED Use Team:obs-ux-infra_services. label Jul 6, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@LikeTheSalad
Copy link
Contributor Author

@elasticmachine merge upstream

},
});

const uploadAndroidMapRoute = createApmServerRoute({
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add docs for this one? (Example: https://www.elastic.co/guide/en/kibana/current/apm-api.html)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @gbamparop - I've just added docs for the overall Android source map API. There are lots of similarities with the RUM one, which is why I took a lot of the parts involved in that part of the doc file. I'm not sure if my approach is the right one, so please have a look just in case there might be a better way to handle it. I'm also looping @bmorelli25 in, in case he's got some inputs as well.

LikeTheSalad and others added 3 commits July 11, 2023 10:42
Co-authored-by: Brandon Morelli <[email protected]>
Co-authored-by: Brandon Morelli <[email protected]>
Co-authored-by: Brandon Morelli <[email protected]>
@bmorelli25
Copy link
Member

@elasticmachine, run elasticsearch-ci/docs

@bmorelli25 bmorelli25 requested a review from a team July 11, 2023 16:59
@LikeTheSalad
Copy link
Contributor Author

@elasticmachine merge upstream

@LikeTheSalad
Copy link
Contributor Author

@elasticmachine merge upstream

options: {
tags: ['access:apm', 'access:apm_write'],
body: { accepts: ['multipart/form-data'] },
body: { accepts: ['multipart/form-data'], maxBytes: 100 * 1024 * 1024 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

According to the core team, this option sets the limit at the route level but there is no option for the user to increase the value. We need to introduce a new config setting for the endpoint.

I think we can proceed with the current approach and handle it in a follow-up work if is needed

fleetId: artifact.id,
created: artifact.created,
mapContent: sourceMapContent,
bundleFilepath: bundleFilePath.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

bundleFilePath is a string. Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I think it's not needed. I've just removed it 👍

Copy link
Contributor

@kpatticha kpatticha left a comment

Choose a reason for hiding this comment

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

LGTM just left 2 comments

@LikeTheSalad
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@LikeTheSalad LikeTheSalad merged commit 6751324 into elastic:main Aug 1, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Aug 1, 2023
ThomThomson pushed a commit to ThomThomson/kibana that referenced this pull request Aug 1, 2023
## Summary

We need a way to decode Android crash's stacktraces so that they can
provide meaningful insights to our customers, this is because, due to
security reasons, android apps tend to obfuscate their code before
publishing it online, making crash reports contain obfuscated names,
which don't make any sense before mapping them to the actual source code
names.

In order to help our customers deobfuscate their stacktraces, we need to
allow them to provide us with an R8 map file, which is generated by the
code obfuscation tool (R8) at compile time. This map file is needed to
later do the deobfuscation process.

So these code changes take care of adding a new endpoint that our
customers can use to upload their map files, similarly to what's
currently available to [RUM
Sourcemaps](https://www.elastic.co/guide/en/apm/guide/current/source-map-how-to.html#source-map-rum-upload),
the Android map files will be uploaded to ES, using the same index as
the one currently used to store RUM Sourcemaps.

There's a couple of reasons why a new endpoint to upload android maps is
needed instead of re-using the existing RUM Sourcemaps one:
* The Sourcemaps upload endpoint has validations in place to check the
sourcemap format, which must be a JSON with some expected keys
available. Android map files don't have a JSON format, so they are
rejected by the sourcemaps endpoint.
* Android map files tend to be large in size, just as an example, the
map file generated for our [sample
app](https://github.com/elastic/opbeans-android) has a size of ~7 MB, so
for real apps this number can be larger, which would also cause issues
with the RUM upload endpoint since it has a max file limit size of 1 MB.
* The RUM upload endpoint contains a parameter (`bundle_filepath `) that
doesn't have an equivalent for the android map use case.

This PR depends on elastic#161152

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Søren Louv-Jansen <[email protected]>
Co-authored-by: Brandon Morelli <[email protected]>
Co-authored-by: Katerina Patticha <[email protected]>
@gbamparop
Copy link
Contributor

Tested on edge-lite by uploading an android sourcemap.

image image

@gbamparop gbamparop added the apm:test-plan-done Pull request that was successfully tested during the test plan label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:test-plan-done Pull request that was successfully tested during the test plan backport:skip This PR does not require backporting release_note:enhancement Team:APM - DEPRECATED Use Team:obs-ux-infra_services. v8.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants