-
Notifications
You must be signed in to change notification settings - Fork 4k
Client-side telemetry is opt-in by default #4396
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
Changes from all commits
dc0c059
1bbc4df
1b73dfc
d4bbb8f
4aeb0d1
e7d65f3
33c51f7
ff4bde9
fa08219
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Net.NetworkInformation; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
|
@@ -52,6 +54,24 @@ public class MetricHelper | |
/// </summary> | ||
private readonly object _lock = new object(); | ||
|
||
private static string _hashMacAddress = string.Empty; | ||
|
||
private static string HashMacAddress | ||
{ | ||
get | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this an instance value instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved offline - let's not test the value of _hashMacAddress in the code that sets the value. |
||
{ | ||
if (_hashMacAddress == string.Empty) | ||
{ | ||
var macAddress = NetworkInterface.GetAllNetworkInterfaces() | ||
.FirstOrDefault(nic => nic.OperationalStatus == OperationalStatus.Up)? | ||
.GetPhysicalAddress()?.ToString(); | ||
_hashMacAddress = macAddress == null ? null : GenerateSha256HashString(macAddress).Replace("-", string.Empty).ToLowerInvariant(); | ||
} | ||
|
||
return _hashMacAddress; | ||
} | ||
} | ||
|
||
public MetricHelper() | ||
{ | ||
if (TestMockSupport.RunningMocked) | ||
|
@@ -177,6 +197,7 @@ private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string, | |
eventProperties.Add("UserId", qos.Uid); | ||
eventProperties.Add("x-ms-client-request-id", qos.ClientRequestId); | ||
eventProperties.Add("UserAgent", AzurePowerShell.UserAgentValue.ToString()); | ||
eventProperties.Add("HashMacAddress", HashMacAddress); | ||
if (qos.InputFromPipeline != null) | ||
{ | ||
eventProperties.Add("InputFromPipeline", qos.InputFromPipeline.Value.ToString()); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 not initialize to
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.
I wanted
null
to represent that there was no valid NIC found. I usedstring.Empty
to represent that we haven't tried to initialize the value of_hashMacAddress
yet