From 4713124437d4038c25aeaf618291aaca064cc094 Mon Sep 17 00:00:00 2001 From: Marco Rogers Date: Tue, 21 Jan 2020 11:38:46 -0800 Subject: [PATCH] Expose context methods for current trace and span (#46) Expose the current trace and current span in the top level scope. These properties are useful for doing custom instrumentation. --- lib/honeycomb-beeline.rb | 3 ++- lib/honeycomb/client.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/honeycomb-beeline.rb b/lib/honeycomb-beeline.rb index 18e876f3..b365e91c 100644 --- a/lib/honeycomb-beeline.rb +++ b/lib/honeycomb-beeline.rb @@ -25,7 +25,8 @@ class << self extend Forwardable attr_reader :client - def_delegators :@client, :start_span, :add_field, :add_field_to_trace + def_delegators :@client, :start_span, :add_field, :add_field_to_trace, + :current_span, :current_trace def configure Configuration.new.tap do |config| diff --git a/lib/honeycomb/client.rb b/lib/honeycomb/client.rb index 5fbee50a..559fc9fd 100644 --- a/lib/honeycomb/client.rb +++ b/lib/honeycomb/client.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require "forwardable" require "honeycomb/beeline/version" require "honeycomb/configuration" require "honeycomb/context" @@ -7,6 +8,10 @@ module Honeycomb # The Honeycomb Beeline client class Client + extend Forwardable + + def_delegators :@context, :current_span, :current_trace + def initialize(configuration:) @client = configuration.client # attempt to set the user_agent_addition, this will only work if the