Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def self.subscribe(
pattern,
notification_payload_transform = nil,
disallowed_notification_payload_keys = [],
kind = nil
kind: nil
)
subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new(
name: pattern,
tracer: tracer,
notification_payload_transform: notification_payload_transform,
disallowed_notification_payload_keys: disallowed_notification_payload_keys,
kind: nil
kind: kind
)

subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def finish(name, id, payload)
_(last_span).wont_be_nil
_(last_span.name).must_equal('foo bar')
_(last_span.attributes['extra']).must_equal('context')
_(last_span.kind).must_equal(:internal)
end

it 'finishes spans even when block subscribers blow up' do
Expand Down Expand Up @@ -260,5 +261,15 @@ def finish(name, id, payload)
_(obj.class).must_equal(ActiveSupport::Notifications::Fanout::Subscribers::Evented)
_(last_span).must_be_nil
end

it 'supports setting the span kind' do
OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo', nil, [], kind: :client)
ActiveSupport::Notifications.instrument('bar.foo', extra: 'context')

_(last_span).wont_be_nil
_(last_span.name).must_equal('foo bar')
_(last_span.attributes['extra']).must_equal('context')
_(last_span.kind).must_equal(:client)
end
end
end