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

Custom Instrumentation produces unreliable data #4616

Open
ehu0716 opened this issue Dec 10, 2024 · 5 comments
Open

Custom Instrumentation produces unreliable data #4616

ehu0716 opened this issue Dec 10, 2024 · 5 comments

Comments

@ehu0716
Copy link

ehu0716 commented Dec 10, 2024

Platform

iOS

Environment

Production

Installed

Swift Package Manager

Version

8.37

Xcode Version

16.0

Did it work on previous versions?

No response

Steps to Reproduce

Our team are employing custom instrumentation to assess the performance of a specific function in our application. However, the data displayed on the dashboard is highly inaccurate, with numerous entries showing durations of days or even weeks, and many others indicating a duration of 0 milliseconds. This makes the data unreliable for evaluating performance effectively.

Expected Result

We shouldn't see data with duration of days, weeks or 0ms.

Actual Result

Wrong data

Image
Image

Are you willing to submit a PR?

No response

@brustolin
Copy link
Contributor

Hello @ehu0716, thanks for reaching out.

Can you share more how are you using custom instructions? Maybe share a repro with us.
Its usage relies heavily on your own strategy, and without knowing your code base we cannot help you.

@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Dec 11, 2024
@brustolin brustolin moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK Dec 11, 2024
@ehu0716
Copy link
Author

ehu0716 commented Dec 12, 2024

Hey @brustolin, thanks for your reply. I can't share the repo with you unfortunately. But we did a really basic custom instrumental with following implementation during App launch.

sentryTransaction = SentrySDK.startTransaction(
            name: "Transaction",
            operation: "init"
        )
sentrySpan = sentryTransaction?.startChild(operation: "span")
one function we want to measure 
sentrySpan?.finish()
sentryTransaction?.finish()

I suspect that while the sentrySpan starts and before the finish method is called, if the user moves the app to the background, the finish method might not be executed until the app is brought back to the foreground. Do you think this is possible?

@brustolin
Copy link
Contributor

Hello @ehu0716.
I meant a way to reproduce the problem, not the repository, my bad if it was not well communicated.

And thants for the repro. I dont think moving the app to the background would halt the function in such way, but I need to test.

But aren't you using something like this:

do {
  sentryTransaction = SentrySDK.startTransaction(
              name: "Transaction",
              operation: "init"
          )
  sentrySpan = sentryTransaction?.startChild(operation: "span")
  try functionToMeasure()
  sentrySpan?.finish()
  sentryTransaction?.finish()
} catch {

}

In this case, if the function throws an exception, the span is never finished, and if the user moves the app to the background and comes back later, somehow you finish the span, then I believe you would end up with the scenario that you described.

@ehu0716
Copy link
Author

ehu0716 commented Dec 12, 2024

@brustolin 😓 my bad, misread your initial reply.
That is a good guess. But we are not wrapping code in do catch. so I reckon my assumption doesn't stand.

@brustolin brustolin moved this from Needs More Information to Needs Discussion in Mobile & Cross Platform SDK Dec 13, 2024
@brustolin
Copy link
Contributor

Got it. We will investigate this.

@philprime philprime moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Status: Needs Investigation
Development

No branches or pull requests

2 participants