Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Jul 10, 2024
1 parent 5beeb47 commit 9230214
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datadog/tracing/transport/serializable_trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def to_msgpack(packer = nil)
end

# convert span events to tags
span.set_tag('events', span.events.map(&:to_hash).to_json) if span.events.count
span.set_tag('events', span.events.map(&:to_hash).to_json) if span.events.count > 0

# DEV: We use strings as keys here, instead of symbols, as
# DEV: MessagePack will ultimately convert them to strings.
Expand Down
1 change: 1 addition & 0 deletions spec/datadog/tracing/span_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
meta: {},
metrics: {},
span_links: [],
span_events: [],
error: 0
)
end
Expand Down
46 changes: 46 additions & 0 deletions spec/datadog/tracing/transport/serializable_trace_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,52 @@
)
end
end

context 'when given span events' do
subject(:unpacked_trace) { MessagePack.unpack(to_msgpack) }

let(:spans) do
Array.new(3) do |_i|
Datadog::Tracing::Span.new(
'dummy',
events: [
Datadog::Tracing::SpanEvent.new(
'event1',
time_unix_nano: 1862312345678901234,
),
Datadog::Tracing::SpanEvent.new(
'event2',
time_unix_nano: 23243675464378901235,
attributes: { 'event.attr' => 'some_val1', 'event.attr2' => 'some_val2' }
)
],
)
end
end

it 'serializes span events' do
expect(
unpacked_trace.map do |s|
s['meta']['events']
end
).to all(
eq(
[
{
'name' => 1,
'time_unix_nano' => 0xffffffffffffffff,
'attributes' => { 'link.name' => 'test_link' }
},
{
'name' => 1,
'time_unix_nano' => 0xffffffffffffffff,
'attributes' => { 'link.name' => 'test_link' }
},
]
)
)
end
end
end

describe '#to_json' do
Expand Down

0 comments on commit 9230214

Please sign in to comment.