Skip to content

Commit a3f5aaf

Browse files
author
Tristan Sloughter
committed
fix tests of attribute, link and event adding to spans
1 parent 5144bc0 commit a3f5aaf

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

apps/opentelemetry/test/opentelemetry_SUITE.erl

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,10 @@ child_spans(Config) ->
365365
update_span_data(Config) ->
366366
Tid = ?config(tid, Config),
367367

368-
Links = [#link{trace_id=0,
369-
span_id=0,
368+
LinkTraceId = otel_id_generator:generate_trace_id(),
369+
LinkSpanId = otel_id_generator:generate_span_id(),
370+
Links = [#link{trace_id=LinkTraceId,
371+
span_id=LinkSpanId,
370372
attributes=[],
371373
tracestate=[]}],
372374

@@ -388,15 +390,26 @@ update_span_data(Config) ->
388390
?assertMatch(SpanCtx1, ?current_span_ctx),
389391
otel_span:end_span(SpanCtx1),
390392

391-
?UNTIL_NOT_EQUAL([], ets:match(Tid, #span{trace_id=TraceId,
392-
span_id=SpanId,
393-
%% TODO: compare this another way since
394-
%% attributes are now a record hidden behind a module
395-
%% attributes=[{<<"key-1">>, <<"value-1">>}],
396-
%% links=Links,
397-
status=Status,
398-
%% events=Events,
399-
_='_'})).
393+
[#span{attributes=A,
394+
links=L,
395+
events=E}] = ?UNTIL_NOT_EQUAL([], ets:match_object(Tid, #span{trace_id=TraceId,
396+
span_id=SpanId,
397+
status=Status,
398+
_='_'})),
399+
400+
401+
?assertMatch(#{<<"key-1">> := <<"value-1">>}, otel_attributes:map(A)),
402+
?assertMatch([#link{trace_id=LinkTraceId,
403+
span_id=LinkSpanId}], otel_links:list(L)),
404+
?assertMatch([#event{system_time_nano=_,
405+
name = <<"event-name">>,
406+
attributes=_},
407+
#event{system_time_nano=_,
408+
name=event_1,
409+
attributes=_}], otel_events:list(E)),
410+
411+
ok.
412+
400413

401414
tracer_instrumentation_library(Config) ->
402415
Tid = ?config(tid, Config),

0 commit comments

Comments
 (0)