-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add Interface to Send Auth Info to Telemetry #421
base: main
Are you sure you want to change the base?
Conversation
eeb4c86
to
ff84672
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 1* Cmdlet telemetry : N * auth telemetry. Conclusion: data structure => array, but only 1 element. Todo: test if array is OK to be stored in kusto?
- telemetry key naming convention. Conclusion: use dash. General conclusion: ?
- Scope. Can we leverage MSAL telemetry? Todo: remove AuthorityUri. Consider adding correlation ID later. Consider enable telemetry of -Environment parameter.
- leverage Beisi & Lei's design. Conclusion: not much.
- Codegen => Todo: next sprint. Create task.
- TokenCacheEnabled => nice to have. Consider risk & effort of testing.
ff84672
to
f6a9cea
Compare
/// <summary> | ||
/// Authentication process succeed or not. | ||
/// </summary> | ||
public bool AuthenticationSuccess { get; set; } = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why presuming it false? Or does it even matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer to set it as negative result biased.
TokenCredentialName = null; | ||
} | ||
|
||
public AuthenticationInfo(IAuthenticationInfo other, bool? isSuccess = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is isSuccess bool?
? In what case will it be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is isSuccess
bool?
? In what case will it be null?
If it is null, use the value in other
. The case doesn't exist in current code.
/// <summary> | ||
/// Get the information to be recorded in Telemetry | ||
/// </summary> | ||
IList<IAuthenticationInfo> GetDataForTelemetry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating a core interface can be risky. We must
- Update all implementation of this interface. I believe there's one in Accounts and another in Accounts' tests.
- Test collaboration of new Accounts and older version of service modules, especially if they use this interface.
ce45e53
to
39e6304
Compare
9f1fa26
to
eabb4e3
Compare
9174668
to
e4b4dc9
Compare
a693ddf
to
4574c39
Compare
9415a08
to
662702c
Compare
662702c
to
92308c0
Compare
No change since last review
|
Cannot use array directly, the current solution is to expand the first (most important) authentication telemetry record and serialize the other parts into a json string
|
/// </summary> | ||
public class AzureCmdletContext : ICmdletContext | ||
{ | ||
private string cmdletId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private string cmdletId; | |
private string _cmdletId; |
suggest using '_' as the prefix of private field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have both private data members that start with lower case and "_". Let get a unified decision for it.
@@ -292,6 +292,20 @@ public void SetPSHost(PSHost host) | |||
{ | |||
} | |||
|
|||
private static void PopulateAuthenticationPropertiesFromQos(AuthenticationTelemetryData telemetry, IDictionary<string, string> eventProperties) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static void PopulateAuthenticationPropertiesFromQos(AuthenticationTelemetryData telemetry, IDictionary<string, string> eventProperties) | |
private static void PopulateAuthenticationPropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string, string> eventProperties) |
because the naming of this function is ...FromQos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Will also discuss with yeming about the naming
/// <param name="cmdletContext">The cmdlet context called from</param> | ||
/// <returns>A client properly authenticated in the given context, properly configured for use with Azure PowerShell, | ||
/// targeting the given named endpoint in the targeted environment</returns> | ||
TClient CreateArmClient<TClient>(IAzureContext context, string endpoint, ICmdletContext cmdletContext) where TClient : ServiceClient<TClient>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain why creating an ArmClient needs cmdletContext?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of partners use Arm Client to handle the authentication. If we want to collect authentication telemetry from their cmdlets, a good way is to add cmdlet context here.
Also the CmdletContext can be treated as the same status as AzureContext. We can pass them both in the same interface.
var record = telemetry?.Head; | ||
if (record != null) | ||
{ | ||
eventProperties[$"{AuthTelemetryRecord.AuthTelemetryPropertyHeadPrefix}-{nameof(record.TokenCredentialName).ToLower()}"] = record.TokenCredentialName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move out of metric helper
The info added
Example To update later