Fixes AB#3549188 add telemetry in the Broker Discovery flow#3040
Fixes AB#3549188 add telemetry in the Broker Discovery flow#3040siddhijain wants to merge 3 commits into
Conversation
|
✅ Work item link check complete. Description contains link AB#3549188 to an Azure Boards work item. |
1 similar comment
|
✅ Work item link check complete. Description contains link AB#3549188 to an Azure Boards work item. |
|
❌ Work item link check failed. Description contains AB#3549188 but the Bot could not link it to an Azure Boards work item. Click here to learn more. |
There was a problem hiding this comment.
Pull request overview
Adds new OpenTelemetry attributes and emits them during Broker Discovery and package state checks to improve diagnosability of broker selection behavior.
Changes:
- Added new
AttributeNameentries for package install/enabled state and Broker Discovery telemetry. - Emitted Broker Discovery telemetry (installed candidate count, reported active brokers, discovery path) in
BrokerDiscoveryClient. - Emitted package install/enabled state telemetry in
PackageHelper.isPackageInstalledAndEnabled(), and added a vNext changelog entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java | Introduces new OTel attribute keys for package state + broker discovery. |
| common/src/main/java/com/microsoft/identity/common/internal/broker/PackageHelper.java | Records new package install/enabled state attributes on the current span. |
| common/src/main/java/com/microsoft/identity/common/internal/activebrokerdiscovery/BrokerDiscoveryClient.kt | Records new broker discovery attributes (counts, reported active brokers, chosen path). |
| changelog.txt | Adds a vNext entry for the telemetry addition. |
| SpanExtension.current().setAttribute(AttributeName.is_installed_by_application_info.name(), isInstalledByApplicationInfo); | ||
| SpanExtension.current().setAttribute(AttributeName.is_enabled_by_application_info.name(), isEnabledByApplicationInfo); | ||
| SpanExtension.current().setAttribute(AttributeName.is_installed_by_package_info.name(), isInstalledByPackageInfo); | ||
| SpanExtension.current().setAttribute(AttributeName.is_enabled_by_enabled_setting.name(), isEnabledByEnabledSetting); | ||
|
|
There was a problem hiding this comment.
isPackageInstalledAndEnabled() sets span attributes (is_installed_by_* / is_enabled_by_*) that are not keyed by package name. In call sites that check multiple packages (e.g., Broker Discovery filters multiple candidates), each invocation overwrites the previous values, so the telemetry ends up representing only the last package checked rather than the overall discovery state. Consider emitting these attributes from the caller with an aggregate (counts/summary) or include a bounded identifier so values aren’t overwritten/misleading.
| SpanExtension.current().setAttribute(AttributeName.is_installed_by_application_info.name(), isInstalledByApplicationInfo); | |
| SpanExtension.current().setAttribute(AttributeName.is_enabled_by_application_info.name(), isEnabledByApplicationInfo); | |
| SpanExtension.current().setAttribute(AttributeName.is_installed_by_package_info.name(), isInstalledByPackageInfo); | |
| SpanExtension.current().setAttribute(AttributeName.is_enabled_by_enabled_setting.name(), isEnabledByEnabledSetting); |
| @@ -1,5 +1,6 @@ | |||
| vNext | |||
| ---------- | |||
| - [MINOR] Add telemetry in the Broker Discovery flow | |||
There was a problem hiding this comment.
Changelog vNext entries in this file consistently include the PR number in parentheses (e.g., (#2679)). This new entry is missing the PR reference, which breaks the established vNext format and makes release notes harder to trace. Update it to include (#<PR_NUMBER>).
| - [MINOR] Add telemetry in the Broker Discovery flow | |
| - [MINOR] Add telemetry in the Broker Discovery flow (#<PR_NUMBER>) |
| //region Package install/enabled state | ||
|
|
||
| /** | ||
| * Indicates if the package is installed according to ApplicationInfo. | ||
| */ | ||
| is_installed_by_application_info, | ||
|
|
||
| /** | ||
| * Indicates if the package is enabled according to ApplicationInfo. | ||
| */ | ||
| is_enabled_by_application_info, | ||
|
|
||
| /** | ||
| * Indicates if the package is installed according to PackageInfo. | ||
| */ | ||
| is_installed_by_package_info, | ||
|
|
||
| /** | ||
| * Indicates if the package is enabled according to the enabled setting. | ||
| */ | ||
| is_enabled_by_enabled_setting, | ||
|
|
||
| //endregion | ||
|
|
||
| //region Broker discovery | ||
|
|
||
| /** | ||
| * The number of broker candidates that are installed and have valid signatures. | ||
| */ | ||
| broker_discovery_installed_candidate_count, | ||
|
|
||
| /** | ||
| * Comma-separated active broker package names returned by each responding candidate. | ||
| */ | ||
| broker_discovery_reported_active_brokers, | ||
|
|
||
| /** | ||
| * The discovery path taken: "cache", "ipc", "account_manager", or "account_manager_fallback". | ||
| */ | ||
| broker_discovery_path, |
There was a problem hiding this comment.
This enum’s header comment notes that changes must be mirrored in the Broker repo’s corresponding AttributeName enum. Since this PR adds new attributes, the Broker repo will also need the same additions to keep telemetry keys consistent across repos. Please ensure the Broker-side enum is updated in a coordinated PR.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
…oker/PackageHelper.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@siddhijain I've opened a new pull request, #3041, to work on those changes. Once the pull request is ready, I'll request review from you. |
…tivebrokerdiscovery/BrokerDiscoveryClient.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
||
| const val ERROR_BUNDLE_KEY = "ERROR_BUNDLE_KEY" | ||
|
|
||
| const val ACCOUNT_MANAGER = "ACCOUNT_MANAGER" |
There was a problem hiding this comment.
brokerdiscoveryclient is on the SDK side (MSAL/OneAuth/WPJ API), we probably don't get telemetry from the former two. is this intentional?
There was a problem hiding this comment.
You're right! I will have to move some of these telemetry data points away from the client side. Similar to enabled settings that might get overridden.
| Logger.verbose(methodTag, "Unable to read enabled setting for package: " + packageName); | ||
| } | ||
|
|
||
| SpanExtension.current().setAttribute(AttributeName.is_installed_by_application_info.name(), isInstalledByApplicationInfo); |
There was a problem hiding this comment.
is there another info we could use? (e.g. is the app in hibernation, deep sleep, etc)
Fixes AB#3549188 add telemetry in the Broker Discovery flow