From f541f41159da54a2c91b6d763ed4580628c82682 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 18 May 2023 10:20:34 -0600 Subject: [PATCH] fix elixir trace_id/span_id types to reference the Erlang types --- apps/opentelemetry_api/lib/open_telemetry.ex | 6 +++--- apps/opentelemetry_api/test/open_telemetry_test.exs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/opentelemetry_api/lib/open_telemetry.ex b/apps/opentelemetry_api/lib/open_telemetry.ex index 0bca4ba2..1b05f8b7 100644 --- a/apps/opentelemetry_api/lib/open_telemetry.ex +++ b/apps/opentelemetry_api/lib/open_telemetry.ex @@ -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() @@ -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()] diff --git a/apps/opentelemetry_api/test/open_telemetry_test.exs b/apps/opentelemetry_api/test/open_telemetry_test.exs index 0a24eb6a..4a81a331 100644 --- a/apps/opentelemetry_api/test/open_telemetry_test.exs +++ b/apps/opentelemetry_api/test/open_telemetry_test.exs @@ -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