question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance monitoring (Custom Instrumentation) logs are not sent on Android

See original GitHub issue

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 4.11.0

react-native version: 0.70.6

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

[Link to issue]

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...@sentry.io/...'
  tracesSampleRate: 1.0, // send transaction always
});

I have following issue:

Performance monitoring (Custom Instrumentation) logs are not sent on Android

Steps to reproduce:

  • Step 1
    • Create new React Native project with npx react-native init SampleApp
  • Step 2
    • Setup sentry according to the document
      • yarn add @sentry/react-native
      • npx @sentry/wizard -i reactNative -p ios android
  • Step 3
    • Setup Performance Monitoring according to the document
import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "https://...",
  tracesSampleRate: 1.0
});

const App: () => Node = () => {
  useEffect(() => {
    const transaction = Sentry.startTransaction({name: 'test-transaction'});
    const span = transaction.startChild({op: 'functionX'});
    // functionCallX
    span.finish();
    transaction.finish();
  }, []);
	...
}
  • Step 4
    • Check Performance Monitoring at Sentry.io

Actual result:

  • ❌ When I run Custom Instrumentation on Android, I cannot see any logs on sentry.io.

  • ✅ No problem with Automatic Instrumentation.

  • ✅ No problem with iOS.

  • ✅ No problem with sentry-react-native v3.4.3. Seems to be a problem with v4 and above.

sentry-react-native Instrumentation iOS Android
v4.11.0 Automatic Instrumentation
Custom Instrumentation
v3.4.3 Automatic Instrumentation
Custom Instrumentation

Expected result:

Custom Instrumentation performance logs to be sent by Android.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
takahi5commented, Dec 13, 2022

@krystofwoldrich @marandaneto Thank you for the support! Transaction appeared in Sentry by adding op. 🎉

1reaction
krystofwoldrichcommented, Dec 12, 2022

@takahi5 The logs look good. Seems like the SDK is sending the data.

Do you maybe have dynamic sampling enabled in the Sentry UI?

Can you also check Logcat, I suspect you will see the following.

 E  Error when deserializing
  java.lang.IllegalStateException: Missing required field "op"
  	at io.sentry.SpanContext$Deserializer.deserialize(SpanContext.java:323)
  	at io.sentry.protocol.Contexts$Deserializer.deserialize(Contexts.java:170)
  	at io.sentry.SentryBaseEvent$Deserializer.deserializeValue(SentryBaseEvent.java:389)
  	at io.sentry.protocol.SentryTransaction$Deserializer.deserialize(SentryTransaction.java:297)
  	at io.sentry.protocol.SentryTransaction$Deserializer.deserialize(SentryTransaction.java:222)
  	at io.sentry.JsonSerializer.deserialize(JsonSerializer.java:121)
  	at io.sentry.OutboxSender.processEnvelope(OutboxSender.java:161)
  	at io.sentry.OutboxSender.processFile(OutboxSender.java:73)
  	at io.sentry.OutboxSender.processEnvelopeFile(OutboxSender.java:110)
  	at io.sentry.android.core.EnvelopeFileObserver.onEvent(EnvelopeFileObserver.java:64)
  	at android.os.FileObserver$ObserverThread.onEvent(FileObserver.java:166)
  	at android.os.FileObserver$ObserverThread.observe(Native Method)
  	at android.os.FileObserver$ObserverThread.run(FileObserver.java:116)

@takahi5 You can try to add op and the transaction should appear in Sentry.

const transaction = Sentry.startTransaction({ name: 'test-transaction', op: 'test-op' });

@markushi @romtsn ~Was op always required on Android or is it some recent change?~ I see it’s from 6.0.0-alpha.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance Monitoring troubleshooting and FAQ - Firebase
If you're not seeing log messages for performance events, try the following troubleshooting steps: Make sure that the Performance Monitoring SDK is not...
Read more >
Troubleshoot the Android Instrumentation
To ensure that it is not actually instrumenting, run gradle with --info flag to show the info logs. You should see the following...
Read more >
Slow rendering - Android Developers
With custom performance monitoring​​ To do this, collect frame render times from specific parts of your app with FrameMetricsAggregator and ...
Read more >
Add custom data to mobile monitoring
For New Relic's mobile monitoring: learn how to send custom data, and which ... create your own data types for custom instrumentation for...
Read more >
Set Up for Android - Sentry Documentation
Profiling depends on Sentry's performance monitoring product being enabled beforehand ... is not sending performance data, try using custom instrumentation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found