Repository navigation
Attach custom child spans to the cold app start transaction #3581
Description
Activity
@zhukic thanks for reaching out! Yes, that's something we've been considering for a while, let me discuss this internally!
In the meantime you could utilize
EventProcessorsto add your custom spans, here's a snippet:
Beware these are internal APIs, so they might not be stable across releases.SentryAndroid.init(this) { options -> options.apply { dsn = ... addEventProcessor(object : EventProcessor { @Suppress("UnstableApiUsage") override fun process( transaction: SentryTransaction, hint: Hint ): SentryTransaction { transaction.contexts.trace?.traceId?.let { traceId -> transaction.spans .firstOrNull { it?.op.equals("app.start.cold") } ?.let { appStartSpan -> val parentSpanId = appStartSpan.spanId val startTimeStamp = 0.0 // unix time in seconds val endTimeStamp = 0.0 // unix time in seconds val op = "component.op" val description = "description" transaction.spans.add( SentrySpan( startTimeStamp, endTimeStamp, traceId, SpanId(), parentSpanId, op, description, SpanStatus.OK, null, emptyMap(), emptyMap(), emptyMap(), emptyMap(), ) ) } } return transaction } }) } }
- moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3
on Jul 17, 2024 @zhukic could you describe your use-case a bit more in detail? Which kind of operations do you want to measure? Is it mainly about the execution of
Application.onCreate()?@markushi Thank you for the answers!
I'll try the approach with the
EventProcessora bit later.could you describe your use-case a bit more in detail? Which kind of operations do you want to measure? Is it mainly about the execution of Application.onCreate()?
During the
Application.onCreate()I initialize lots of my app's components and it takes some time. I'd like to have a possibility to measure all the initializations separately and attach them as the child spans to theapplication.loadspan.The second use case is described here. It's my code which runs on the UI thread, and currently, it's marked as "Missing instrumentation". I'd also like to have a possibility to attach it as a child span. I guess, this can be also solved by a custom
EventProcessor.@zhukic thanks for the details, that's very helpful! On a side note - would you be interested if we provided auto-instrumentation for those components that get initialized as part of
Application.onCreate? We have some ideas on how to to do that, although it may become a bit noisy, but we can think of some configuration/ignorelist.7 remaining items
- moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3
on Jul 22, 2024 @zhukic Glad it's working for you! Actually it should be safer to use
BeforeSendTransactionCallbackinstead of a customEventProcessor, as theBeforeSendTransactionCallbackis executed after all processors.Internal reference: JAVA-359
Supported in the next released version using the new extend app start API (only enabled in combination with
options.enableStandaloneAppStartTracing) See: #5604
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsNo status

Problem Statement
Hi!
I use the performance v2 feature, and as the next step, I'd like to measure specific operations time during the
application.loadoperation, for example, and enrich the transaction with more detailed spans.I haven't found the proper way to do this at the moment.
Could you please suggest if there is some workaround to do that using the current API(custom callbacks or event processor?)
Expected behaviour: possibility to add child spans to the existing spans(
application.load,activity.load, etc.) during cold app start.SDK version -
7.9.0Thank you!
Solution Brainstorm
No response