Repository navigation
[Mono.Android] Add runtime startup tracing API - #13779
Draft
simonrozsival wants to merge 2 commits into
Draft
simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
Expose opt-in startup and Activity lifecycle spans through an in-process API so tooling can observe Android app behavior without adding an exporter dependency. Startup spans are retained until a listener is registered, preserving phase timing and parentage for late consumers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Emit `android.runtime.gc_bridge.process` from the `Microsoft.Android.Runtime` source after each managed GC bridge pass, and add a separate fine-grained `Microsoft.Android.Runtime.Interop` source for per-class native registration, peer creation, and type map cache misses in both directions. Traces have no levels, so the separate source is the opt-in for higher-volume interop data. Costly tags (a JNI call for the Java class name in `create_peer`) are gated on `IsAllDataRequested`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Android tooling needs a way to observe managed startup and Activity lifecycle without requiring an exporter or adding an OpenTelemetry SDK dependency to the runtime. This change adds an opt-in runtime tracing API that exposes those spans through
ActivitySource, retains startup phase timing until a listener is registered, and replays the original span hierarchy to late consumers. It also documents consumer setup and adds focused on-device coverage.Startup tracing is disabled by default. The startup root covers managed initialization rather than earlier process/native startup; Activity lifecycle spans describe framework notifications, not the full duration of overridden Activity methods.
Each managed GC bridge pass emits
android.runtime.gc_bridge.process(component, cross-reference, and collected counts) after processing completes. Fine-grained interop spans use a separateMicrosoft.Android.Runtime.Interopsource, so listening to it is the opt-in for higher-volume data: per-classregister_natives,create_peer, and type map cache misses in both directions.ActivitySource.StartActivityreturnsnullwithout a sampling listener, and the JNI-dependentcreate_peerclass-name tag is gated onIsAllDataRequested. Interop spans are not buffered during startup, and their overhead with a listener attached has not been measured.Validation:
make prepare CONFIGURATION=Debug && make leeroy CONFIGURATION=Debug MSBUILD_ARGS='-m:4 -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false'— passed../dotnet-local.sh build -t:Install -c Debug -p:Device=emulator-5588 -p:IncludeCategories=AndroidTelemetry -p:AndroidTelemetryStartupTracing=true tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj— passed.(cd tests/Mono.Android-Tests/Mono.Android-Tests && ../../../dotnet-local.sh test Mono.Android.NET-Tests.csproj --no-build -c Debug --report-trx --results-directory ../../../bin/TestDebug/TestResults -p:Device=emulator-5588 -p:IncludeCategories=AndroidTelemetry -p:AndroidTelemetryStartupTracing=true)— passed: 2 tests, 0 failures.make leeroy, then the install and test commands above with--device emulator-5588and withoutAndroidTelemetryStartupTracing— passed: 4 tests, 0 failures.