From c52cb00df9d0a286420e06f1bfb8a4d33d1d287b Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 10 Jun 2022 15:30:54 +1200 Subject: [PATCH 1/2] Restore monkey patch introducing `[]` and `[]=` to span instances. --- lib/traces/backend/datadog/interface.rb | 6 ++++++ spec/traces/backend/datadog_spec.rb | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/traces/backend/datadog/interface.rb b/lib/traces/backend/datadog/interface.rb index f6e5d95..a24f1e7 100644 --- a/lib/traces/backend/datadog/interface.rb +++ b/lib/traces/backend/datadog/interface.rb @@ -25,6 +25,12 @@ require 'traces/context' require_relative 'version' +# We introduce some compatibility interfaces for getting and setting tags: +module Datadog::Tracing::Metadata::Tagging + alias []= set_tag + alias [] get_tag +end + module Traces module Backend module Datadog diff --git a/spec/traces/backend/datadog_spec.rb b/spec/traces/backend/datadog_spec.rb index 52a29c1..83654f7 100644 --- a/spec/traces/backend/datadog_spec.rb +++ b/spec/traces/backend/datadog_spec.rb @@ -66,6 +66,14 @@ def my_span_and_context it {is_expected.to be == "my_span"} end + + describe '#[]=' do + before {span["my_key"] = "tag_value"} + + subject(:value) {span["my_key"]} + + it {is_expected.to be == "tag_value"} + end end describe Datadog::Tracing::TraceOperation do From 75f8225369c850a57ff441d344280529d3fb2250 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 10 Jun 2022 15:39:02 +1200 Subject: [PATCH 2/2] Rework datadog requires. --- lib/traces/backend/datadog/interface.rb | 2 +- spec/spec_helper.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/traces/backend/datadog/interface.rb b/lib/traces/backend/datadog/interface.rb index a24f1e7..8b065bb 100644 --- a/lib/traces/backend/datadog/interface.rb +++ b/lib/traces/backend/datadog/interface.rb @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require 'ddtrace' +require 'datadog/tracing' require 'traces/context' require_relative 'version' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0c93054..3fdcff9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,12 +20,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require 'datadog/tracing' +require 'ddtrace' -Datadog.configure do |config| - # To enable debug mode - # config.diagnostics.debug = true -end +# Datadog.configure do |config| +# # To enable debug mode +# config.diagnostics.debug = true +# end require "bundler/setup" require "traces/backend/datadog"