Open nkomonen-amazon opened 6 days ago
Thought experiement: in the places where this PR currently calls, ReAuthReasonState.setReason
, why can't we use telemetry.aws_loginWithBrowser.record({reAuthReason: ...})
instead?
If the answer is "because the execution context might be lost by the time we emit telemetry.aws_loginWithBrowser
, then next questions are:
telemetry.xx.record()
state that is built-up, is preserved until telemetry.xx.run()
is called?telemetry.xx.recordNext()
which maintains state that is used for whenever the next xx
metric is emitted.
Problem:
In the reauth metric (
aws_loginWithBrowser
+isReAuth: true
) we didn't know why the user needed to reauth. It could have been due to regular expiration or some unexpected error.Solution:
Add a new field in
aws_loginWithBrowser
namedreAuthReason
which will have some sort of identifier for why reauth was needed.On a technical level, we save the reason an SSO connection was invalidated in our cache using the ReAuthReasonState class. Then when it comes time to do a reauth we will grab the past value from that state and set it in the metric.
The reauth reason can be set in a few places, but some examples are when the token refresh process fails, we will know that this is the cause for the user needing to reauth.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.