You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/msal-browser/docs/performance.md
+79Lines changed: 79 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,3 +50,82 @@ const msalInstance = new msal.PublicClientApplication({
50
50
}
51
51
});
52
52
```
53
+
54
+
## Measuring performance
55
+
56
+
Applications that want to measure the performance of authentication flows in MSAL.js can do so manually, or consume the performance measures taken by the library itself.
57
+
58
+
### addPerformanceCallback
59
+
60
+
Since version `@azure/[email protected]`, applications can register a callback to receive performance measurements taken by the library. These measurement will include end-to-end measurements for top-level APIs, as well as measurements for important internal APIs.
61
+
62
+
**Note for MSFT first-party applications**: We will be publishing an internal build of `@azure/msal-browser` that is already instrumented to capture this telemetry. Contact us for more details.
The complete details for `PerformanceEvents` objects can be found [here](../../msal-common/src/telemetry/performance/PerformanceEvent.ts). Below is a list of some notable properties:
|`name`|`string`| Name of the operation, usually matches the top-level API name (e.g. `acquireTokenSilent`, `acquireTokenByCode`, `ssoSilent`). |
107
+
|`durationMs`|`number`| End-to-end duration in milliseconds for the operation. |
108
+
|`success`|`boolean`| Whether the operation was successful or not. |
109
+
|`fromCache`|`boolean`| Whether the operation retrieved the result from the cache. |
110
+
|`correlationId`|`string`| Correlation ID used for the operation (preferably unique per request). |
111
+
|`libraryVersion`|`string`| Version of MSAL.js used for the operation. |
112
+
|`authority`|`string`| Authority used for the operation. |
113
+
|`<internalFunctionName>DurationMs`|`number`| Duration in milliseconds for an internal operation. |
114
+
115
+
### removePerformanceCallback
116
+
117
+
The `addPerformanceCallback` API will return a callback id, which an application can pass to `PublicClientApplication.removePerformanceCallback` to unregister that callback from receiving performance events. It will return a boolean indicating whether or not the callback was successfully removed.
0 commit comments