Skip to content

Instrument correlation between silent and interactive requests #7146

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

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

konstantin-msft
Copy link
Collaborator

  • Instrument correlation between silent and interactive requests

@github-actions github-actions bot added msal-browser Related to msal-browser package msal-common Related to msal-common package labels Jun 5, 2024
@github-actions github-actions bot added the documentation Related to documentation. label Jun 5, 2024
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration
generateRequestThumbprint(request: SilentRequest | SsoSilentRequest | PopupRequest | RedirectRequest): string;
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
Copy link
Member

Choose a reason for hiding this comment

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

nit: Are these duplicated?

@konstantin-msft konstantin-msft force-pushed the telemetry_correlate_silent_and_interactive_calls branch from 47299f2 to 2671e45 Compare January 21, 2025 13:54
* Serializes thumbprint map entries when redirect begins
* Rehydrates thumbprint map when returning from redirect
* Adds embeddedClientId to perf thumbprint when available
* @return string
*/
getThumbprintMapSerialized(): string {
const toArray = (map : any) : any =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can probably simplify this with const stringifiedThumbprints = JSON.stringify(Array.from(this.thumbprints.entries()))

@@ -93,6 +93,7 @@ export const TemporaryCacheKeys = {
CORRELATION_ID: "request.correlationId",
NATIVE_REQUEST: "request.native",
REDIRECT_CONTEXT: "request.redirect.context",
THUMBPRINTS: "thumbprints",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

THUMBPRINTS: "thumbprints", -> THUMBPRINTS: "request.telemetry.thumbprints",

PerformanceEvents.AcquireTokenRedirect,
PerformanceEvents.AcquireTokenPopup,
]
PerformanceEvents.AcquireTokenSilent.toString(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can use event.name in Object.values([PerformanceEvents.AcquireTokenSilent, ...]) to avoid converting each entry to string

]
PerformanceEvents.AcquireTokenSilent.toString(),
PerformanceEvents.SsoSilent.toString(),
].includes(event.name)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ditto

]
PerformanceEvents.AcquireTokenSilent.toString(),
PerformanceEvents.SsoSilent.toString(),
].includes(event.name)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ditto

@@ -500,6 +511,13 @@ export class RedirectClient extends StandardInteractionClient {
);
}

// Not sure if this is the right place for this logic to live
// Read thumbprints from temporary cache if PerformanceClient is not 3P
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Read thumbprints from temporary cache if PerformanceClient is not 3P -> Read thumbprints from temporary cache if PerformanceClient is instance of BrowserPerformanceClient. Please remove this comment as code below is pretty clear

@@ -114,6 +115,16 @@ export class RedirectClient extends StandardInteractionClient {
validRequest.loginHint || "",
validRequest.account || null
);

// Cache thumbprints for telemetry linking if PerformanceClient is not 3P
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Read thumbprints from temporary cache if PerformanceClient is not 3P -> Read thumbprints from temporary cache if PerformanceClient is instance of BrowserPerformanceClient. Please remove this comment as code below is pretty clear

@@ -1337,6 +1345,15 @@ export class BrowserCacheManager extends CacheManager {
return parsedRequest;
}

getCachedThumbprints(): string {
const cachedThumbprintsSerialized = this.getTemporaryCache(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can be simplified with

 return this.getTemporaryCache(...) || ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation. msal-browser Related to msal-browser package msal-common Related to msal-common package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants