Skip to content

Commit

Permalink
update elixir tests for new links, events and attribute limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Sloughter committed Dec 16, 2021
1 parent 9e40f06 commit e6d7e23
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions test/otel_tests.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ defmodule OtelTests do
Tracer.set_attributes([{"attr-2", "value-2"}])
end

attributes = :otel_attributes.new([{"attr-1", "value-1"}, {"attr-2", "value-2"}], 128, :infinity)

assert_receive {:span,
span(
name: "span-1",
attributes: [{"attr-1", "value-1"}, {"attr-2", "value-2"}]
attributes: ^attributes
)}
end

Expand All @@ -48,17 +50,21 @@ defmodule OtelTests do

span_ctx(span_id: parent_span_id) = Span.end_span(s1)

attributes = :otel_attributes.new([], 128, :infinity)

assert_receive {:span,
span(
name: "span-1",
attributes: []
attributes: ^attributes
)}

attributes = :otel_attributes.new([{"attr-1", "value-1"}, {"attr-2", "value-2"}], 128, :infinity)

assert_receive {:span,
span(
name: "span-2",
parent_span_id: ^parent_span_id,
attributes: [{"attr-1", "value-1"}, {"attr-2", "value-2"}]
attributes: ^attributes
)}
end

Expand All @@ -71,10 +77,12 @@ defmodule OtelTests do

assert span_ctx() = Span.end_span(s)

attributes = :otel_attributes.new([{"attr-1", "value-1"}, {"attr-2", "value-2"}], 128, :infinity)

assert_receive {:span,
span(
name: "span-2",
attributes: [{"attr-1", "value-1"}, {"attr-2", "value-2"}]
attributes: ^attributes
)}
end

Expand Down Expand Up @@ -150,11 +158,13 @@ defmodule OtelTests do
ret = Task.await(task)
assert :hello = ret

links = :otel_links.new([OpenTelemetry.link(parent)], 128, 128, :infinity)

assert_receive {:span,
span(
name: "child",
parent_span_id: :undefined,
links: [_]
links: ^links
)}

assert span_ctx() = Span.end_span(parent)
Expand Down Expand Up @@ -188,11 +198,13 @@ defmodule OtelTests do
assert span_ctx() = Span.end_span(s2)
assert span_ctx() = Span.end_span(s3)

attributes = :otel_attributes.new([{"attr-1", "value-1"}, {"attr-2", "value-2"}], 128, :infinity)

assert_receive {:span,
span(
name: "span-1",
parent_span_id: :undefined,
attributes: [{"attr-1", "value-1"}, {"attr-2", "value-2"}]
attributes: ^attributes
)}

assert_receive {:span,
Expand Down Expand Up @@ -227,19 +239,25 @@ defmodule OtelTests do

stacktrace = Exception.format_stacktrace(__STACKTRACE__)

attributes = :otel_attributes.new([
{"exception.type", "Elixir.RuntimeError"},
{"exception.message", "my error message"},
{"exception.stacktrace", stacktrace}
], 128, :infinity)

assert_receive {:span,
span(
name: "span-4",
events: [
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.RuntimeError"},
{"exception.message", "my error message"},
{"exception.stacktrace", ^stacktrace}
]
)
]
events: {
:events,
128,
128,
:infinity,
0,
[
{:event, _, "exception", ^attributes}
]
}
)}
end
end
Expand Down

0 comments on commit e6d7e23

Please sign in to comment.