Skip to content

Commit

Permalink
spec the new new method
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Goldsmith <[email protected]>
  • Loading branch information
robbkidd and MikeGoldsmith committed Jun 5, 2024
1 parent 0043945 commit e20bb1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class BaggageSpanProcessor < OpenTelemetry::SDK::Trace::SpanProcessor
# @param [lambda] baggage_key_predicate A lambda that takes a baggage key and returns true if
# the key should be added to the span as an attribute, false otherwise.
def initialize(baggage_key_predicate)
raise ArgumentError, 'baggage_key_predicate must respond to :call (lambda/Proc)' unless baggage_key_predicate.respond_to?(:call)

@baggage_key_predicate = baggage_key_predicate
super()
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
end
end

describe '#new' do
it 'requires a callable baggage_key_predicate' do
_(-> { OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new }).must_raise(ArgumentError)
err = _(-> { OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new(:not_a_callable) }).must_raise(ArgumentError)
_(err.message).must_match(/must respond to :call/)
end
end

describe '#on_start' do
describe 'with the ALLOW_ALL_BAGGAGE_KEYS predicate' do
it 'adds current baggage keys/values as attributes when a span starts' do
Expand Down

0 comments on commit e20bb1d

Please sign in to comment.