diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb index 41efeb94a0..8c9e879e88 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb @@ -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) diff --git a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb index 4b6b596d72..61afd26fad 100644 --- a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb +++ b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb @@ -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 @@ -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