Skip to content

Commit

Permalink
Update honeycomb trace ENV var to new name
Browse files Browse the repository at this point in the history
This is to align this with the conversation and changes in honeycombio/buildevents#74
  • Loading branch information
DavidS committed Dec 9, 2020
1 parent 0848c83 commit ad849b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions lib/puppet_litmus/puppet_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions lib/puppet_litmus/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet_litmus/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down

0 comments on commit ad849b7

Please sign in to comment.