Skip to content

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

Merged
merged 9 commits into from
Aug 8, 2017

Conversation

cormacpayne
Copy link
Member

@cormacpayne cormacpayne commented Aug 1, 2017

Description

Fix for issue #4179 and #4330

  • Client-side telemetry is now opt-in by default
    • The old AzureDataCollectionProfile.json file will be removed and replaced by AzurePSDataCollectionProfile.json
    • Previously set environment variables will still be respected
    • Updated warning messages for cmdlets to use for enabling/disabling telemetry
  • Added HashMacAddress to telemetry

This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

twitchax
twitchax previously approved these changes Aug 1, 2017
@@ -52,6 +53,31 @@ public class MetricHelper
/// </summary>
private readonly object _lock = new object();

private static string _hashMacAddress = string.Empty;
Copy link
Contributor

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?

Copy link
Member Author

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 used string.Empty to represent that we haven't tried to initialize the value of _hashMacAddress yet

_hashMacAddress = GenerateSha256HashString(macAddress).Replace("-", string.Empty).ToLowerInvariant();
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole thing could be reduced to

var physicalAddress = nics.FirstOrDefault(nic => nic.OperationalStatus == OperationalStatus.Up)?.GetPhysicalAddress();
if(physicalAddress != null)
    _hashMacAddress = GenerateSha256HashString(macAddress.ToString()).Replace("-", string.Empty).ToLowerInvariant();

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, not the whole thing...the loopy part.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll clean that up. I always forget about Linq 😄

To enable data collection: PS &gt; Enable-AzureDataCollection

Select Y to enable data collection [Y/N]:</value>
Use the Disable-AzureRmDataCollection cmdlet to turn the feature Off. The cmdlet can be found in the AzureRM.Profile module. To disable data collection: PS &amp;gt; Disable-AzureRmDataCollection.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want the PS >?

@cormacpayne
Copy link
Member Author

@azuresdkci test this please

InitializeDataCollectionProfile();

if (!_dataCollectionProfile.EnableAzureDataCollection.HasValue && CheckIfInteractive())
if (_dataCollectionProfile.EnableAzureDataCollection.HasValue || !CheckIfInteractive())
Copy link
Member

Choose a reason for hiding this comment

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

We should no longer need this (and in fact, we should remove this method if it is not used elsewhere (except tests)


private static string HashMacAddress
{
get
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this an instance value instead?

Copy link
Member

Choose a reason for hiding this comment

The 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.

{
var macAddress = NetworkInterface.GetAllNetworkInterfaces()
.FirstOrDefault(nic => nic.OperationalStatus == OperationalStatus.Up)?
.GetPhysicalAddress().ToString();
Copy link
Contributor

Choose a reason for hiding this comment

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

You actually need an elvis operator preceding the ToString() since the preceding code can evaluate to null.

var macAddress = NetworkInterface.GetAllNetworkInterfaces()
    .FirstOrDefault(nic => nic.OperationalStatus == OperationalStatus.Up)?
    .GetPhysicalAddress()?.ToString();

@cormacpayne cormacpayne changed the base branch from preview to release-4.3.0 August 4, 2017 16:04
@cormacpayne
Copy link
Member Author

@@ -52,6 +54,24 @@ public class MetricHelper
/// </summary>
private readonly object _lock = new object();

private string _hashMacAddress = string.Empty;

private string HashMacAddress
Copy link
Member

Choose a reason for hiding this comment

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

this can be static

@markcowl markcowl merged commit 4fd2472 into Azure:release-4.3.0 Aug 8, 2017
@twitchax
Copy link
Contributor

twitchax commented Aug 8, 2017

👍

@cormacpayne cormacpayne deleted the telemetry-fix branch November 9, 2017 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants