ruby-sdk/test/instrumentation_test_helper.rb
Topher Bullock 0645351585 Internal Release 0.3.0
Add configurable exception reporter
Avoid leaking tool exceptions by sending them to a configurable exception reporter
Add optional context to pass to tools
Add basic instrumentation data/labels
2025-05-08 17:37:54 -04:00

24 lines
660 B
Ruby

# frozen_string_literal: true
module InstrumentationTestHelper
class Instrumentation
attr_reader :callback
attr_reader :data
def initialize
@callback = ->(data) { @data = data }
end
end
def instrumentation_helper
@instrumentation_helper ||= Instrumentation.new
end
def assert_instrumentation_data(expected_data)
data = instrumentation_helper.data.dup
duration = data.delete(:duration)
assert_not_nil(duration, "Duration is not set")
assert_operator(duration, :>=, 0, "Duration is not positive or zero")
assert_equal(expected_data, data, "Instrumentation data does not match expected data")
end
end