From ad849b73ac191a69ca060ae10cd35804ce114421 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 9 Dec 2020 11:02:13 +0000 Subject: [PATCH] Update honeycomb trace ENV var to new name This is to align this with the conversation and changes in https://github.com/honeycombio/buildevents/pull/74 --- lib/puppet_litmus/puppet_helpers.rb | 16 ++++++++-------- lib/puppet_litmus/rake_helper.rb | 18 +++++++++--------- lib/puppet_litmus/rake_tasks.rb | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/puppet_litmus/puppet_helpers.rb b/lib/puppet_litmus/puppet_helpers.rb index 2aaa18d2..762a27d4 100644 --- a/lib/puppet_litmus/puppet_helpers.rb +++ b/lib/puppet_litmus/puppet_helpers.rb @@ -9,7 +9,7 @@ module PuppetLitmus::PuppetHelpers # @return [Boolean] The result of the 2 apply manifests. def idempotent_apply(manifest) Honeycomb.start_span(name: 'litmus.idempotent_apply') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header manifest_file_location = create_manifest_file(manifest) apply_manifest(nil, expect_failures: false, manifest_file_location: manifest_file_location) apply_manifest(nil, catch_changes: true, manifest_file_location: manifest_file_location) @@ -39,7 +39,7 @@ def idempotent_apply(manifest) # @return [Object] A result object from the apply. def apply_manifest(manifest, opts = {}) Honeycomb.start_span(name: 'litmus.apply_manifest') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.manifest', manifest) span.add_field('litmus.opts', opts) @@ -117,7 +117,7 @@ def apply_manifest(manifest, opts = {}) # @return [String] The path to the location of the manifest. def create_manifest_file(manifest) Honeycomb.start_span(name: 'litmus.create_manifest_file') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.manifest', manifest) require 'tmpdir' @@ -154,7 +154,7 @@ def create_manifest_file(manifest) # @return [Bool] Success. The file was succesfully writtne on the target. def write_file(content, destination) Honeycomb.start_span(name: 'litmus.write_file') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.destination', destination) require 'tmpdir' @@ -191,7 +191,7 @@ def write_file(content, destination) # @return [Object] A result object from the command. def run_shell(command_to_run, opts = {}) Honeycomb.start_span(name: 'litmus.run_shell') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.command_to_run', command_to_run) span.add_field('litmus.opts', opts) @@ -228,7 +228,7 @@ def run_shell(command_to_run, opts = {}) # @return [Object] A result object from the command. def bolt_upload_file(source, destination, opts = {}, options = {}) Honeycomb.start_span(name: 'litmus.bolt_upload_file') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.source', source) span.add_field('litmus.destination', destination) span.add_field('litmus.opts', opts) @@ -280,7 +280,7 @@ def bolt_upload_file(source, destination, opts = {}, options = {}) # @return [Object] A result object from the task.The values available are stdout, stderr and result. def run_bolt_task(task_name, params = {}, opts = {}) Honeycomb.start_span(name: 'litmus.run_task') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.task_name', task_name) span.add_field('litmus.params', params) span.add_field('litmus.opts', opts) @@ -348,7 +348,7 @@ def run_bolt_task(task_name, params = {}, opts = {}) # @return [Object] A result object from the script run. def bolt_run_script(script, opts = {}, arguments: []) Honeycomb.start_span(name: 'litmus.bolt_run_script') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.script', script) span.add_field('litmus.opts', opts) span.add_field('litmus.arguments', arguments) diff --git a/lib/puppet_litmus/rake_helper.rb b/lib/puppet_litmus/rake_helper.rb index f3782e15..2ccd1150 100644 --- a/lib/puppet_litmus/rake_helper.rb +++ b/lib/puppet_litmus/rake_helper.rb @@ -9,8 +9,8 @@ config.client = Libhoney::NullClient.new end end -process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV['HTTP_X_HONEYCOMB_TRACE']) -ENV['HTTP_X_HONEYCOMB_TRACE'] = process_span.to_trace_header +process_span = Honeycomb.start_span(name: "litmus: #{([$PROGRAM_NAME] + ($ARGV || [])).join(' ')}", serialized_trace: ENV['HONEYCOMB_TRACE']) +ENV['HONEYCOMB_TRACE'] = process_span.to_trace_header Honeycomb.add_field_to_trace('litmus.pid', Process.pid) if defined? PuppetLitmus::VERSION Honeycomb.add_field_to_trace('litmus.version', PuppetLitmus::VERSION) @@ -103,7 +103,7 @@ def get_metadata_operating_systems(metadata) # @return [Object] the standard out stream. def run_local_command(command) Honeycomb.start_span(name: 'litmus.run_local_command') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.command', command) require 'open3' @@ -127,7 +127,7 @@ def provision(provisioner, platform, inventory_vars, append_cli = nil) Honeycomb.add_field_to_trace('litmus.provisioner', provisioner) Honeycomb.start_span(name: 'litmus.provision') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.platform', platform) task_name = provisioner_task(provisioner) @@ -161,7 +161,7 @@ def provision_list(provision_hash, key) def tear_down_nodes(targets, inventory_hash) Honeycomb.start_span(name: 'litmus.tear_down_nodes') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.targets', targets) include ::BoltSpec::Run @@ -181,7 +181,7 @@ def tear_down_nodes(targets, inventory_hash) def tear_down(node_name, inventory_hash) Honeycomb.start_span(name: 'litmus.tear_down') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header # how do we know what provisioner to use span.add_field('litmus.node_name', node_name) @@ -197,7 +197,7 @@ def tear_down(node_name, inventory_hash) def install_agent(collection, targets, inventory_hash) Honeycomb.start_span(name: 'litmus.install_agent') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.collection', collection) span.add_field('litmus.targets', targets) @@ -289,7 +289,7 @@ def build_modules_in_folder(source_folder) # @return a bolt result def install_module(inventory_hash, target_node_name, module_tar, module_repository = nil, ignore_dependencies = false) # rubocop:disable Style/OptionalBooleanParameter Honeycomb.start_span(name: 'install_module') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header span.add_field('litmus.target_node_name', target_node_name) span.add_field('litmus.module_tar', module_tar) @@ -345,7 +345,7 @@ def uninstall_module(inventory_hash, target_node_name, module_to_remove = nil, * def check_connectivity?(inventory_hash, target_node_name) Honeycomb.start_span(name: 'litmus.check_connectivity') do |span| - ENV['HTTP_X_HONEYCOMB_TRACE'] = span.to_trace_header + ENV['HONEYCOMB_TRACE'] = span.to_trace_header # if we're only checking connectivity for a single node if target_node_name span.add_field('litmus.target_node_name', target_node_name) diff --git a/lib/puppet_litmus/rake_tasks.rb b/lib/puppet_litmus/rake_tasks.rb index f479111c..141c10da 100644 --- a/lib/puppet_litmus/rake_tasks.rb +++ b/lib/puppet_litmus/rake_tasks.rb @@ -375,7 +375,7 @@ at_exit { exit! } env = options[:env].nil? ? {} : options[:env] - env['HTTP_X_HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header + env['HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header stdout, stderr, status = Open3.capture3(env, test) ["\n================\n#{title}\n", stdout, stderr, status] end @@ -393,7 +393,7 @@ spinners = TTY::Spinner::Multi.new("[:spinner] Running against #{targets.size} targets.") payloads.each do |title, test, options| env = options[:env].nil? ? {} : options[:env] - env['HTTP_X_HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header + env['HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header spinners.register("[:spinner] #{title}") do |sp| stdout, stderr, status = Open3.capture3(env, test) if status.to_i.zero?