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

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

Closed
5 of 11 tasks
takahi5 opened this issue Dec 8, 2022 · 6 comments · Fixed by #2691
Closed
5 of 11 tasks

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

takahi5 opened this issue Dec 8, 2022 · 6 comments · Fixed by #2691

Comments

@takahi5
Copy link

takahi5 commented Dec 8, 2022

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://[email protected]/...'
  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.

@marandaneto
Copy link
Contributor

@takahi5 can you enable debug: true in the SDK init and check the logs?

@takahi5
Copy link
Author

takahi5 commented Dec 8, 2022

@marandaneto Thank you for your support.

Here is the log with debug: true.

LOG  Sentry Logger [log]: Integration installed: ModulesLoader
 LOG  Sentry Logger [log]: Unhandled promise rejections will be caught by Sentry.
 LOG  Sentry Logger [log]: Integration installed: ReactNativeErrorHandlers
 LOG  Sentry Logger [log]: Integration installed: Release
 LOG  Sentry Logger [log]: Integration installed: InboundFilters
 LOG  Sentry Logger [log]: Integration installed: FunctionToString
 LOG  Sentry Logger [log]: Integration installed: Breadcrumbs
 LOG  Sentry Logger [log]: Integration installed: LinkedErrors
 LOG  Sentry Logger [log]: Integration installed: Dedupe
 LOG  Sentry Logger [log]: Integration installed: HttpContext
 LOG  Sentry Logger [log]: Integration installed: EventOrigin
 LOG  Sentry Logger [log]: Integration installed: SdkInfo
 LOG  Sentry Logger [log]: Integration installed: DebugSymbolicator
 LOG  Sentry Logger [log]: Integration installed: RewriteFrames
 LOG  Sentry Logger [log]: Integration installed: DeviceContext
 LOG  Sentry Logger [log]: [ReactNativeTracing] Native frames instrumentation initialized.
 LOG  Sentry Logger [log]: [ReactNativeTracing] Not instrumenting route changes as routingInstrumentation has not been set.
 LOG  Sentry Logger [log]: Integration installed: ReactNativeTracing
 LOG  Running "SampleApp70" with {"rootTag":11}
 LOG  >>>> startTransaction
 LOG  Sentry Logger [log]: [Tracing] starting undefined transaction - test-transaction
 LOG  Sentry Logger [log]: [Tracing] Starting 'functionX' span on transaction 'test-transaction' (915cd4c61e877e23).
 LOG  Sentry Logger [log]: [Tracing] Finishing 'functionX' span on transaction 'test-transaction' (915cd4c61e877e23).
 LOG  >>>> finishTransaction
 LOG  Sentry Logger [log]: [Measurements] Adding measurements to transaction {
  "stall_count": {
    "value": 0,
    "unit": "none"
  },
  "stall_total_time": {
    "value": 0,
    "unit": "millisecond"
  },
  "stall_longest_time": {
    "value": 0,
    "unit": "millisecond"
  }
}
 LOG  Sentry Logger [log]: [Tracing] Finishing undefined transaction: test-transaction.
 LOG  Sentry Logger [log]: [NativeFrames] Native frames timed out for undefined transaction test-transaction. Not adding native frames measurements.

I ran the following code of measurement.

  useEffect(() => {
    console.log('>>>> startTransaction');
    const transaction = Sentry.startTransaction({name: 'test-transaction'});
    const span = transaction.startChild({op: 'functionX'}); // This function returns a Span
    // functionCallX
    span.finish(); // Remember that only finished spans will be sent with the transaction
    console.log('>>>> finishTransaction');
    transaction.finish(); // Finishing the transaction will send it to Sentry
  }, []);

@krystofwoldrich
Copy link
Member

krystofwoldrich commented 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

@marandaneto marandaneto moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK Dec 12, 2022
@marandaneto
Copy link
Contributor

I believe name and op are required, so let's double check that, otherwise the fix would be on JS directly + fixing our samples on the docs.

@takahi5
Copy link
Author

takahi5 commented Dec 13, 2022

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

@krystofwoldrich krystofwoldrich moved this from Needs More Information to In Progress in Mobile & Cross Platform SDK Dec 13, 2022
Repository owner moved this from In Progress to Done in Mobile & Cross Platform SDK Dec 14, 2022
@ilkanozen
Copy link

#948
Its helped to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants