DataDog / dd-sdk-flutter

Flutter bindings and tools for utilizing Datadog Mobile SDKs
Apache License 2.0
43 stars 42 forks source link

Not able to able mapping file to datadog #591

Closed vikashkr786 closed 5 months ago

vikashkr786 commented 5 months ago

Describe the issue

I am trying to upload mapping.txt file (not empty) from my android application I referred to https://docs.datadoghq.com/real_user_monitoring/error_tracking/mobile/android/?tab=us#upload-your-mapping-file

Reproduction steps

These are the steps I performed: 1) Placed mapping.txt to build/app/outputs/mapping/{variant}/mapping.txt 2) datadog{ site = "US5" mappingFilePath = "D:\IO_2\app-flutter\build\app\outputs\mapping\release\mapping.txt" } added this to buil.gradle 3) added DD_API_KEY to gradle.properties 4) Run this command in terminal : ./gradlew uploadMappingRelease getting this error:

Execution failed for task ':app:uploadMappingRelease'.

Error while evaluating property 'buildId' of task ':app:uploadMappingRelease' java.io.FileNotFoundException: D:\IO_2\app-flutter\build\app\generated\datadog\buildId\release\datadog.buildId (The system cannot find the path specified)

Can someone help in uploading the mapping file to datadog?

Device Information

No response

SDK version

implementation "com.datadoghq:dd-sdk-android-rum:2.8.0"

Kotlin / Java version

No response

Gradle / AGP version

No response

Other dependencies versions

No response

Other relevant information

No response

0xnm commented 5 months ago

Hello @vikashkr786! To have buildId file generated you need to assemble your project before doing mapping file upload. Did you do it? If yes and you still have this error, please post the command you use to build your project.

vikashkr786 commented 5 months ago

Hello @vikashkr786! To have buildId file generated you need to assemble your project before doing mapping file upload. Did you do it? If yes and you still have this error, please post the command you use to build your project.

Hello @0xnm , Yeah that worked now. Thankyou

vikashkr786 commented 5 months ago

I successfully uploaded the file using ./gradlew uploadMappingRelease but still I am not able to see trace correctly. can you tell why it is not working??This i am getting Deobfuscation failed: The stack trace could not be deobfuscated because no mapping files could be found for this application. If you are not obfuscating your application, ignore this message. Otherwise, upload your mapping files to see deobfuscated stack traces. You can view all your uploaded files on the RUM Debug Symbols page.

0xnm commented 5 months ago

Can you please check that buildId attribute attached to your RUM error event matches the build ID which was printed during the mapping file upload? Otherwise, if it is missing in the RUM error event, you should have matching service,variant,version tags in the event.

vikashkr786 commented 5 months ago

The buildId are different in datadog RUM event and the id which generated . Also, the variant tag is empty for the uploaded file. what to do to solve this?

fuzzybinary commented 5 months ago

Hi @vikashkr786

It looks like you're using Flutter so @0xnm transferred this over to the Flutter repo. If that's the case, you do not have to use the Android Gradle Plugin and instead should use datadog-ci as documented here

vikashkr786 commented 5 months ago

Hi Jeff, I have configured Datadog into into my android SDK and using it in my flutter application using plugins. So I should follow the documentation you sent me above and remove the Android plugin from my flutter application build.gradle file??

On Fri, Apr 19, 2024, 5:37 PM Jeff Ward @.***> wrote:

Hi @vikashkr786 https://github.com/vikashkr786

It looks like you're using Flutter so @0xnm https://github.com/0xnm transferred this over to the Flutter repo. If that's the case, you do not have to use the Android Gradle Plugin and instead should use datadog-ci as documented here https://docs.datadoghq.com/real_user_monitoring/error_tracking/mobile/flutter/#upload-symbol-files-to-datadog

— Reply to this email directly, view it on GitHub https://github.com/DataDog/dd-sdk-flutter/issues/591#issuecomment-2066434226, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ7YKT2B7TMITCXIP3V32JTY6ECJLAVCNFSM6AAAAABGOV646KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWGQZTIMRSGY . You are receiving this because you were mentioned.Message ID: @.***>

fuzzybinary commented 5 months ago

That would be my general recommendation, yes.

By integrating only the Android SDK, you won't get any information about that Dart / Flutter portions of your application. This includes the symbolication / deobfuscation of any Dart code, as the Android mapping file does not contain any Dart symbols (only Java mappings).

However this could depend on your use case. Can you explain a bit more about your situation? Is there a reason you're not using the Flutter SDK?

vikashkr786 commented 5 months ago

Actually my company works both on Android as well as IOS app. For Android, the native code is written in Java in Android SDK. The Flutter application makes use of Java plugins . So here, I configured Datadog SDK into my Android SDK. Now I want to upload mapping files from flutter application so it can be traced. So what do you suggest here ?

Also, can I upload mapping file directly from my android SDK?

On Fri, Apr 19, 2024, 6:33 PM Jeff Ward @.***> wrote:

That would be my general general recommendation, yes.

By integrating only the Android SDK, you won't get any information about that Dart / Flutter portions of your application. This includes the symbolication / deobfuscation of any Dart code, as the Android mapping file does not contain any Dart symbols (only Java mappings).

However this could depend on your use case. Can you explain a bit more about your situation? Is there a reason you're not using the Flutter SDK?

— Reply to this email directly, view it on GitHub https://github.com/DataDog/dd-sdk-flutter/issues/591#issuecomment-2066532580, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ7YKT5DTBE7Y7KBOWF56LLY6EIYVAVCNFSM6AAAAABGOV646KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWGUZTENJYGA . You are receiving this because you were mentioned.Message ID: @.***>

fuzzybinary commented 5 months ago

Okay, I believe this is possible but there are a huge number pitfalls you have to be careful of:

If the build_ids match that should be enough to get deobfuscation to work for with newer Android SDKs. Having a matching variant is only necessary if you're using an older Android SDK or if you're using the Flutter SDK.

Currently there's no easy / supported way of doing a manual upload, but both datadog-ci and the gradle plugin are open source, so you can refer to the implementations to see what we do.

vikashkr786 commented 5 months ago

I initialised Datadog into Android SDK for logs and RUM. I am getting logs and also RUM events from application. I am facing issues in uploading mapping file for trace. I uploaded mapping file from my application but it is not working. I can view the file also in Datadog but in that the variant tag is empty. So I am confused how can I make the mapping file upload correctly.

On Fri, Apr 19, 2024, 7:11 PM Jeff Ward @.***> wrote:

Okay, I believe this is possible but there are a huge number pitfalls you have to be careful of:

  • Currently, if you initialize Datadog Sdk in your Android code, you cannot also use it in Flutter without some extra steps.
  • When using the Android SDK + the Datadog Android Gradle Plugin, deobfuscation uses the build_id, whereas Flutter currently does not, so using the Datadog Android Gradle plugin will break Flutter deobfuscation and symbolication.
  • build_id is generated for each application build to uniquely identify it. uploadMappingRelease should take an existing build into account, but this means that you need to make sure you run it immediately after flutter build apk and ensure that compile steps aren't rerun.

Currently there's no easy / supported way of doing a manual upload, but both datadog-ci and the gradle plugin are open source, so you can refer to the implementations to see what we do.

— Reply to this email directly, view it on GitHub https://github.com/DataDog/dd-sdk-flutter/issues/591#issuecomment-2066616636, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ7YKTZZAIFVBIEGA6VGDQDY6ENINAVCNFSM6AAAAABGOV646KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWGYYTMNRTGY . You are receiving this because you were mentioned.Message ID: @.***>

fuzzybinary commented 5 months ago

Sorry, I edited my above comment to add information about variant:

If the build_ids match that should be enough to get deobfuscation to work for with newer Android SDKs. Having a matching variant is only necessary if you're using an older Android SDK or if you're using the Flutter SDK.

The use of build_id in Android is new, and unfortunately our symbols explorer doesn't show the value yet. This should be fixed soon.

So to answer your question -- as long as the build_id being reported in your events matches the build_id sent when you uploaded the mapping file, everything should work. This should be the case so long as you run uploadMappingRelease immediately after running your Flutter build, so long as gradle doesn't attempt to re-run your build for some reason.

vikashkr786 commented 5 months ago

Okay what I concluded is : if the buildId of each RUM events matches the buildId while uploading the mapping then it should work So each RUM event will have buildId same as in buildId file ??

On Fri, Apr 19, 2024, 7:59 PM Jeff Ward @.***> wrote:

Sorry, I edited my above comment to add information about variant:

If the build_ids match that should be enough to get deobfuscation to work for with newer Android SDKs. Having a matching variant is only necessary if you're using an older Android SDK or if you're using the Flutter SDK.

The use of build_id in Android is new, and unfortunately our symbols explorer doesn't show the value yet. This should be fixed soon.

So to answer your question -- as long as the build_id being reported in your events matches the build_id sent when you uploaded the mapping file, everything should work. This should be the case so long as you run uploadMappingRelease immediately after running your Flutter build, so long as gradle doesn't attempt to re-run your build for some reason.

— Reply to this email directly, view it on GitHub https://github.com/DataDog/dd-sdk-flutter/issues/591#issuecomment-2066705558, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ7YKT6ZSMPSAMAROYJIIYLY6ES4LAVCNFSM6AAAAABGOV646KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWG4YDKNJVHA . You are receiving this because you were mentioned.Message ID: @.***>

fuzzybinary commented 5 months ago

So each RUM event will have buildId same as in buildId file

Yes -- at least every Error event, though I'm pretty sure it is sent with all events.

vikashkr786 commented 5 months ago

I will try if somehow I get buildId matched for each event. Can I somehow get to see variant name reflecting in Datadog as currently it is empty

On Fri, Apr 19, 2024, 8:07 PM Jeff Ward @.***> wrote:

So each RUM event will have buildId same as in buildId file

Yes -- at least every Error event, though I'm pretty sure it is sent with all events.

— Reply to this email directly, view it on GitHub https://github.com/DataDog/dd-sdk-flutter/issues/591#issuecomment-2066720830, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ7YKTYYLBNYCMLD3NNDOZLY6ET2VAVCNFSM6AAAAABGOV646KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRWG4ZDAOBTGA . You are receiving this because you were mentioned.Message ID: @.***>

fuzzybinary commented 5 months ago

It is a parameter when initializing the SDK: https://docs.datadoghq.com/real_user_monitoring/mobile_and_tv_monitoring/setup/android/?tab=kotlin#initialize-datadog-sdk-with-application-context

vikashkr786 commented 5 months ago

I am getting 2 buildId , 1 in debug folder and 1 in release. Which id should match the RUM event? Okay so i run the apk in release mode and crashed it The buildId for crash event and the buildId in released matched but still it showing that the Deobfuscation failed....

I am attaching configurations and other required data as well below: ddlog2 ddlog4 ddlog5

fuzzybinary commented 5 months ago

Hi @vikashkr786 ,

Can you show me the stack trace that you're getting? With Flutter there are 3 different stack traces that are possible and depending on how you crashed the app will determine if we're doing the right file uploads.

Also, your Datadog API keys are sensitive information, please do not post them places. I would recommend you revoke and rotate that your API key as soon as possible.

vikashkr786 commented 5 months ago

Hi @fuzzybinary ,

This is what i am getting even after uploading mapping file: ddlog6

I crashed the app by throwing a RunTime Exception in the code. This is from sample android project and not from flutter. I tried same from simple android project and still its not working.

fuzzybinary commented 5 months ago

I'd have to look into why that error is showing, but this stack isn't obfuscated. My guess is since you're not obfuscating your code, you're not actually getting a valid JVM mapping file.

vikashkr786 commented 5 months ago

In my sample android app, first I am adding DD_API_KEY to gradle.properties file and then I am running these commands: ./gradlew assembleRelease ./gradlew uploadMappingRelease ./gradlew installRelease

I am still not getting variant in uploaded file even though I have added variant as "release" in configuration. Can you tell why the variant tag is showing empty after uploading mapping file?

fuzzybinary commented 5 months ago

@vikashkr786 Can you reach out to support for help? They'll be better able to assist you getting everything set up properly.

vikashkr786 commented 5 months ago

Okay @fuzzybinary , I will do it.

Thankyou

eury-fsl commented 5 months ago

@vikashkr786 Could you fix the duplicated buildId issue?

vikashkr786 commented 5 months ago

@eury-fsl Yeah I was able to fix that by re-uploading the file after running the application.