sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Allow adding manual app start spans

Open philipphofmann opened this issue 1 year ago • 7 comments

Description

Currently, you can't add manual app start spans to the app start transaction directly after you call SentrySDK.start, because the app start transaction starts when the OS initializes the first UIViewController, which happens a bit after calling SentrySDK.start. The SDK could start the app start transaction sooner and bind it to the scope, so users can attach manual app start spans. We have to point this out in the Changelog because SentrySDK.span won't be nil anymore directly after calling SentrySDK.start. I think it's even safer to do this in the next major as a breaking change.

philipphofmann avatar Nov 30 '23 13:11 philipphofmann

@philipphofmann I'm not sure if this is the limitation you describe but... I'm seeing an issue where starting a transaction with bindToScope: false does not place the transaction into the distributed trace (i.e. connect it with other services on the dashboard). But with bindToScope: true it does. Is it currently possible to manually start a transaction at app start without binding it to the scope and have it linked with the other services? Or is this basically the limitation described in this issue?

    self.connectingTransaction = SentrySDK.startTransaction(
        name: "connecting",
        operation: "default",
            bindToScope: true // false does not result in transaction being connected to other services
    )

wcwynn avatar Mar 08 '24 10:03 wcwynn

I'm seeing an issue where starting a transaction with bindToScope: false does not place the transaction into the distributed trace

That shouldn't be related to that issue. If I'm not mistaken, distributed tracing should work no matter what value you choose for bindToScope. Can you confirm @brustolin?

philipphofmann avatar Mar 11 '24 14:03 philipphofmann

I'm actually a bit unclear on what is meant by this issue. What would a manual app start span be?

I assumed the app start spans are the ones we create in sentryBuildAppStartSpans, but those aren't really "started", they're created after the fact with time information gathered even before SentrySDK.startWithOptions. But you said

the app start transaction starts when the OS initializes the first UIViewController, which happens a bit after calling SentrySDK.start

Are you referring to the ui.load: loadView child span all the way towards the bottom right of this screenshot? But there are others that happen much earlier. image

@philipphofmann, could you please add some links to code so we can see which spans you're talking about?

armcknight avatar Mar 11 '24 19:03 armcknight

We start the app start transaction a bit after starting the SDK. Creating spans even before starting the SDK or shortly after doesn't work right now. This issue aims to solve this problem. Is it clearer now @armcknight?

philipphofmann avatar Mar 12 '24 12:03 philipphofmann

If I'm not mistaken, distributed tracing should work no matter what value you choose for bindToScope. Can you confirm @brustolin?

If I got this right, I don't think it will, because the only scenario where their other service would receive the trace ID is if the HTTP request is part of the entire transaction. For this to function, the transaction must be within the scope.

brustolin avatar Mar 12 '24 12:03 brustolin

We start the app start transaction a bit after starting the SDK. Creating spans even before starting the SDK or shortly after doesn't work right now. This issue aims to solve this problem. Is it clearer now @armcknight?

I think it's clearer now. To restate, this work will allow customers to add manual spans to our automatic app start transaction. Correct?

armcknight avatar Mar 12 '24 18:03 armcknight

To restate, this work will allow customers to add manual spans to our automatic app start transaction. Correct?

Yes, indeed 👍.

philipphofmann avatar Mar 13 '24 14:03 philipphofmann