Skip to content

Commit 871ddb4

Browse files
authored
fix: default span kind (#1034)
* fix: default span kind to follow spec * fix: set default span kind in internal create api * fix: add simple test for span kind default * chore: appease the cop
1 parent 3233377 commit 871ddb4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

sdk/lib/opentelemetry/sdk/trace/tracer_provider.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ def add_span_processor(span_processor)
126126
end
127127

128128
# @api private
129-
def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, instrumentation_library) # rubocop:disable Metrics/MethodLength
129+
def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, instrumentation_library) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
130130
trace_id ||= @id_generator.generate_trace_id
131+
kind ||= :internal
131132
result = @sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
132133
span_id = @id_generator.generate_span_id
133134
if result.recording? && !@stopped

sdk/test/opentelemetry/sdk/trace/tracer_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
_(tracer.start_root_span(nil).name).wont_be_nil
2525
end
2626

27+
it 'defaults to span kind internal when not specified' do
28+
_(tracer.start_root_span(nil).kind).must_equal(:internal)
29+
end
30+
2731
it 'returns a valid span' do
2832
span = tracer.start_root_span('root')
2933
_(span.context).must_be :valid?

0 commit comments

Comments
 (0)