Skip to content

Commit

Permalink
fix elixir trace_id/span_id types to reference the Erlang types
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed May 18, 2023
1 parent 371b2cb commit f541f41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions apps/opentelemetry_api/lib/open_telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ defmodule OpenTelemetry do
the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes
is considered invalid.
"""
@type trace_id() :: non_neg_integer()
@type trace_id() :: :opentelemetry.trace_id()

@typedoc """
SpanId is a unique identifier for a span within a trace, assigned when the span
is created. The ID is an 8-byte array. An ID with all zeroes is considered
invalid.
"""
@type span_id() :: non_neg_integer()
@type span_id() :: :opentelemetry.span_id()

@type attribute_key() :: :opentelemetry.attribute_key()
@type attribute_value() :: :opentelemetry.attribute_value()
Expand Down Expand Up @@ -167,7 +167,7 @@ defmodule OpenTelemetry do
Creates a list of `t:link/0` from a list of 4-tuples.
"""
@spec links([
{integer(), integer(), attributes_map(), tracestate()}
{trace_id(), span_id(), attributes_map(), tracestate()}
| span_ctx()
| {span_ctx(), attributes_map()}
]) :: [link()]
Expand Down
10 changes: 5 additions & 5 deletions apps/opentelemetry_api/test/open_telemetry_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ defmodule OpenTelemetryTest do
end

test "link creation" do
ctx = span_ctx(trace_id: 1, span_id: 2, tracestate: [])
ctx = span_ctx(trace_id: <<1::128>>, span_id: <<2::64>>, tracestate: [])

%{trace_id: t, span_id: s, attributes: a, tracestate: ts} = OpenTelemetry.link(ctx)

assert 1 == t
assert 2 == s
assert <<1::128>> == t
assert <<2::64>> == s
assert [] == ts
assert %{} == a

%{trace_id: t, span_id: s, attributes: a, tracestate: ts} =
OpenTelemetry.link(ctx, [{"attr-1", "value-1"}])

assert 1 == t
assert 2 == s
assert <<1::128>> == t
assert <<2::64>> == s
assert [] == ts
assert %{"attr-1" => "value-1"} == a
end
Expand Down

0 comments on commit f541f41

Please sign in to comment.