Skip to content
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

Telemetry #3: Implement Telemetry in msal-node #1921

Merged
merged 30 commits into from
Sep 10, 2020
Merged

Conversation

tnorling
Copy link
Collaborator

@tnorling tnorling commented Jul 9, 2020

This PR builds on PR #1917 to enable sending Telemetry data to eSTS via 2 extra headers on all /token calls

Responsibilities of each library are:

msal-common:

  • Provides TelemetryManager class
  • Add Telemetry headers to each /token request
  • Clear telemetry related cache items on successful network call (Does not matter if the auth request itself is successful or not, just that the server acknowledged the request)
  • SilentFlowClient increments cache hit counter each time tokens are returned from the cache

msal-browser, msal-node, etc:

  • Instantiate instance of TelemetryManager with apiId, correlationId, cache implementation, forceRefresh value (silent calls only)
  • Pass Telemetry instance to authCodeClient and silentFlowClient
  • Cache errors

@github-actions github-actions bot added the msal-node Related to msal-node package label Jul 9, 2020
@tnorling tnorling linked an issue Jul 13, 2020 that may be closed by this pull request
3 tasks
Copy link
Contributor

@sangonzal sangonzal left a comment

Choose a reason for hiding this comment

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

Overall looks good. You might be able to avoid some code duplication by creating an acquire token common API that takes in a BaseClient and ClientConfiguration and calls acquireToken, logs, and cachesFailedRequests

lib/msal-node/src/utils/Constants.ts Show resolved Hide resolved
lib/msal-node/src/client/ClientApplication.ts Show resolved Hide resolved
Copy link
Collaborator Author

@tnorling tnorling left a comment

Choose a reason for hiding this comment

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

Still need to add the new telemetry CacheSchemaType to the Node Storage class

@tnorling tnorling changed the base branch from msal-common-MSER-Telemetry to dev August 3, 2020 23:45
@coveralls
Copy link

coveralls commented Aug 4, 2020

Coverage Status

Coverage decreased (-0.008%) to 83.168% when pulling 0475b8d on msal-node-MSER-Telemetry into 126b83b on dev.

@github-actions github-actions bot added the msal-common Related to msal-common package label Aug 6, 2020
@tnorling tnorling changed the base branch from dev to msal-node-storage-optimization August 6, 2020 17:47
@github-actions github-actions bot added the samples Related to the samples apps for the library. label Aug 6, 2020
@tnorling tnorling removed the samples Related to the samples apps for the library. label Aug 12, 2020
@tnorling tnorling changed the base branch from msal-node-storage-optimization to dev September 2, 2020 19:33
refreshTokenClientConfig
);
return refreshTokenClient.acquireToken(validRequest);
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure the catch is always telemetry initialization error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not. The catch is for any error that occurs in the flow so that Telemetry can properly cache it

acquireTokenByCode = 871,
acquireTokenByRefreshToken = 872,
acquireTokenByDeviceCode = 671
};
Copy link
Member

Choose a reason for hiding this comment

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

Are they no API ids for confidential clients? Are we adding it later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the callout. Confidential Client wasn't built out yet when this PR was first put up. Will add.

Copy link
Member

@sameerag sameerag left a comment

Choose a reason for hiding this comment

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

two comments, approved.

@tnorling tnorling merged commit aa74343 into dev Sep 10, 2020
@tnorling tnorling deleted the msal-node-MSER-Telemetry branch September 29, 2020 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-common Related to msal-common package msal-node Related to msal-node package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[msal-node] Support MSER Telemetry
5 participants