Skip to content
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

[SHACK-188] telemetry cleanup tasks #134

Merged
merged 6 commits into from
May 16, 2018

Conversation

marcparadise
Copy link
Member

@marcparadise marcparadise commented May 16, 2018

Several cleanup tasks:

  1. use acceptance endpoint when dev mode is true
  2. don't track 'run_mode' in teleemtry data anymore, now that 'dev' runs will go to acceptance
  3. test coverage for Telemeter::enabled?
  4. make sure we send the right chef-cli version to telemetry by capturing the version at time of run in the telemetry session wrapper.
  5. Create a GUID unique to installation on first run and include it with telemetry payload
    Individual commit messages have some more details.

@marcparadise marcparadise requested a review from a team May 16, 2018 16:14
@marcparadise marcparadise force-pushed the SHACK-188/telemetry-cleanup-tasks branch from fe38dbe to b24385b Compare May 16, 2018 18:28
tyler-ball
tyler-ball previously approved these changes May 16, 2018
Copy link
Contributor

@tyler-ball tyler-ball left a comment

Choose a reason for hiding this comment

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

All about those improvements!

Copy link
Contributor

@robbkidd robbkidd left a comment

Choose a reason for hiding this comment

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

Couple of questions and suggestions.

run_timestamp: run_timestamp,
host_platform: host_platform,
event_data: data
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

begin
File.read(ChefCLI::Config.telemetry_installation_identifier_file).chomp
rescue
ChefCLI::Log.info "could not read #{ChefCLI::Config.telemetry_installation_identifier_file} - using default id"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this sort of user output something that should be defined in the i18n data?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, just a log entry. The user need not know or care about this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

OOOOOH, yea. LOG. Right.

if ChefCLI::Telemeter.enabled?
# dev mode telemetry gets sent to a different location
if ChefCLI::Config.telemetry.dev && !ENV.has_key?("CHEF_TELEMETRY_ENDPOINT")
ENV["CHEF_TELEMETRY_ENDPOINT"] = "https://telemetry-acceptance.chef.io"
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about an or-equals here instead of the longer if && statement?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

it "configures the environment to submit to the Acceptance telemetry endpoint" do
subject.run
expect(ENV["CHEF_TELEMETRY_ENDPOINT"]).to eq "https://telemetry-acceptance.chef.io"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Also should test the case for when the env var is set and doesn't get overriden:

Maybe:

it "uses an endpoint the user has set in the environment" do
  allow(ENV).to receive(:[]).with("CHEF_TELEMETRY_ENDPOINT").and_return("http://localhost:5432")
  subject.run
  expect(ENV["CHEF_TELEMETRY_ENDPOINT"]).to eq "http://localhost:5432"
end

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

* when telemetry.dev is true, use the acceptance endpoint for telemetry
* when telemetry is disabled, just clean up the session files and don't
send.  Even though the telemetry gem would not actually submit them
when disabled, seeing workstation logs stating that we're sending
telemetry files when it's disabled could be easily misunderstood.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Since we're now using a different endpoint to submit to when in dev
mode, we don't need to capture telemetry_mode = dev|prod in the
telemetry data.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Capture the version of chef-cli in the telemetry session data,
so that we can be sure we're sending the right version to telemetry

This prevents the following scenario:
* customer runs command under version 1.0.1
* customer upgrades
* customer runs command under version 1.0.2
  * telemetry submits previous 1.0.1 session as version 1.0.2

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Every event will now include a unique installation_id, which is a GUID
we generate at the same time as other first-run tasks. We store it in
CHefCLI::Config.telemetry_installation_identiifer_file ->
.chef-workstation/installation_id.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
…sent

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
@marcparadise marcparadise force-pushed the SHACK-188/telemetry-cleanup-tasks branch from 4c8603e to af340d8 Compare May 16, 2018 21:05
@marcparadise
Copy link
Member Author

Updated with review comment fixes

Copy link
Contributor

@robbkidd robbkidd left a comment

Choose a reason for hiding this comment

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

i like what you've done here

@marcparadise marcparadise merged commit cb6638a into master May 16, 2018
@chef-ci chef-ci deleted the SHACK-188/telemetry-cleanup-tasks branch May 16, 2018 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants