Skip to content

Add telemetry for the switch browser protocol #2612

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

Merged
merged 9 commits into from
Apr 15, 2025
Merged

Conversation

p3dr0rv
Copy link
Contributor

@p3dr0rv p3dr0rv commented Mar 25, 2025

Adding telemetry for Switch browser protocol.

How to read the data?

  • ATIInteractively.is_switch_browser_protocol indicates that the client is sending a switch browser protocol.
  • SwitchBrowserProtocol.is_switch_browser_request_handled indicates that the webview received a switch browser redirect URL and launched the browser with the following characteristics: browser_package_name, is_custom_tabs_supported.
  • SwitchBrowserProtocol.is_switch_browser_resume_handled indicates that the broker redirect URL in the browser was received and handled by the webview.

In conclusion, in a successful scenario, we should have 2 SwitchBrowserProtocol entries: one for the request and another for the resume, and the parent span_id should be the ATIInteractively span_id.

Example

android_spans
| where EventInfo_Time between(ago(1d)..now())
| where DeviceInfo_Model == "SM-G988U"
| where DeviceInfo_Id == "3f0fa7b42bed152f"
| project span_name,trace_id, span_id, parent_span_id, is_switch_browser_protocol, browser_package_name, is_custom_tabs_supported, is_switch_browser_request_handled, is_switch_browser_resume_handled
| order by trace_id

span_name trace_id span_id parent_span_id is_switch_browser_protocol browser_package_name is_custom_tabs_supported is_switch_browser_request_handled is_switch_browser_resume_handled
ATIInteractively 8a92ec54a756969a499d70d67901abb6 bb2b33d4b17f8dae 2dc57e2a0a44e41f true        
AcquireTokenInteractive 8a92ec54a756969a499d70d67901abb6 2dc57e2a0a44e41f 0000000000000000          
SwitchBrowserProtocol 8a92ec54a756969a499d70d67901abb6 7f2edab5f5801692 bb2b33d4b17f8dae   com.android.chrome true true  
SwitchBrowserProtocol 8a92ec54a756969a499d70d67901abb6 71f66086a4c6c15a bb2b33d4b17f8dae         true
SwitchBrowserProtocol 81f98ddfaf5dad5fa511d3afe4a7cb37 e8275d7dab01427d e5d0a07c8d826a5f   com.android.chrome true true  
SwitchBrowserProtocol 81f98ddfaf5dad5fa511d3afe4a7cb37 20e90241b19c1f1e e5d0a07c8d826a5f         true
ATIInteractively 81f98ddfaf5dad5fa511d3afe4a7cb37 e5d0a07c8d826a5f d771e73d1ddcfacf true        
AcquireTokenInteractive 81f98ddfaf5dad5fa511d3afe4a7cb37 d771e73d1ddcfacf 0000000000000000          

Related PR: https://github.com/AzureAD/ad-accounts-for-android/pull/3069

Copy link

❌ Work item link check failed. Description does not contain AB#{ID}.

Click here to Learn more.

@p3dr0rv p3dr0rv marked this pull request as ready for review March 25, 2025 20:09
@p3dr0rv p3dr0rv requested a review from a team as a code owner March 25, 2025 20:09
) : IChallengeHandler<SwitchBrowserChallenge, Unit> {

val span: Span by lazy {
OTelUtility.createSpanFromParent(SpanName.SwitchBrowserProtocol.name, spanContext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not an existing span at this point? Seems excessive to create a new span for this

Copy link
Contributor Author

@p3dr0rv p3dr0rv Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we launch the intent to WebView, there is no active span in this context. You can look at other features that capture telemetry at this point and then create a new span.

Example: in AzureActiveDirectoryWebViewClient
is_sso_nonce_found_in_ests_request is not captured as the span doesn't exist.
We need to create spans like we do for ProcessNonceFromEstsRedirect, ProcessCrossCloudRedirect, Fido.

#2209

cc: @shahzaibj

@shahzaibj
Copy link
Contributor

Why parent span id is ATIInteractively? Why is it not AcquireTokenInteractive?

@shahzaibj
Copy link
Contributor

I think prior to releasing this we need to increase the sampling rate for interactive requests, otherwise we will lose important data

@shahzaibj
Copy link
Contributor

Since you are doing /process and /resume in separate span records, then why even have a generic SwitchBrowserProtocol span? Perhaps instead should have 2 distinct spans: SwitchBrowserProcess and SwitchBrowserResume with their own sets of required fields.

That said, +1 to Fadi's comment, we should see if we can put the information directly on AcquireTokenInteractive spans to save cost.

@p3dr0rv
Copy link
Contributor Author

p3dr0rv commented Apr 9, 2025

Why parent span id is ATIInteractively? Why is it not AcquireTokenInteractive?

I think we can remove it, seems like an unnecessary span all this data can be in AcquireTokenInteractive span.
All the places where ATIInteractively is called come from a AcquireTokenInteractive span

But removing this can be dangerous and affect dashboards or materialized views, so we might want to do this in a different PR

@p3dr0rv
Copy link
Contributor Author

p3dr0rv commented Apr 9, 2025

en have a generic SwitchBrowserProtocol span? Perhaps instead should have 2 distinct spans: SwitchBrowse

Yes, I am fine with that.

@fadidurah
Copy link
Contributor

Why parent span id is ATIInteractively? Why is it not AcquireTokenInteractive?

I think we can remove it, seems like an unnecessary span all this data can be in AcquireTokenInteractive span. All the places where ATIInteractively is called come from a AcquireTokenInteractive span

But removing this can be dangerous and affect dashboards or materialized views, so we might want to do this in a different PR

Maybe we should flight it?

@p3dr0rv p3dr0rv requested a review from a team as a code owner April 15, 2025 20:41
@p3dr0rv p3dr0rv merged commit 13c86dd into dev Apr 15, 2025
24 of 25 checks passed
@p3dr0rv p3dr0rv deleted the pedroro/telemetry-for-duna branch April 15, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants