Add test
diff --git a/src/passage_pd.erl b/src/passage_pd.erl
index 119444d..0958adc 100644
--- a/src/passage_pd.erl
+++ b/src/passage_pd.erl
@@ -179,7 +179,7 @@
-spec set_tags(Tags) -> ok when
Tags :: passage:tags() | fun (() -> passage:tags()).
set_tags(Tags) ->
- update_current_span(fun (Span) -> passage_span:set_tags(Span, Tags) end).
+ update_current_span(fun (Span) -> passage:set_tags(Span, Tags) end).
%% @doc Sets the baggage items of the current span to `Items'.
%%
@@ -189,7 +189,7 @@
-spec set_baggage_items(Items) -> ok when
Items :: passage:baggage_items() | fun (() -> passage:baggage_items()).
set_baggage_items(Items) ->
- update_current_span(fun (Span) -> passage_span:set_baggage_items(Span, Items) end).
+ update_current_span(fun (Span) -> passage:set_baggage_items(Span, Items) end).
%% @doc Returns the baggage items carried by the current span.
-spec get_baggage_items() -> passage:baggage_items().
diff --git a/test/passage_tests.erl b/test/passage_tests.erl
index 49d7965..d53c70b 100644
--- a/test/passage_tests.erl
+++ b/test/passage_tests.erl
@@ -66,6 +66,19 @@
?assertEqual(#{foo => bar, baz => qux, 111 => 333},
passage_span:get_tags(FinishedSpan))
end},
+ {"tag function",
+ fun () ->
+ ok = start_test_tracer(),
+ Span0 =
+ passage:start_span(
+ root, [{tracer, test_tracer}, {tags, #{foo => bar, 111 => 222}}]),
+ Span1 = passage:set_tags(Span0, fun () -> #{baz => qux, 111 => 333} end),
+
+ passage:finish_span(Span1),
+ [FinishedSpan] = finished_spans(),
+ ?assertEqual(#{foo => bar, baz => qux, 111 => 333},
+ passage_span:get_tags(FinishedSpan))
+ end},
{"baggage item",
fun () ->
ok = start_test_tracer(),
@@ -80,6 +93,22 @@
?assertEqual(#{<<"foo">> => <<"bar">>, <<"baz">> => <<"qux">>},
passage:get_baggage_items(ChildSpan1))
end},
+ {"baggage item function",
+ fun () ->
+ ok = start_test_tracer(),
+ RootSpan0 = passage:start_span(root, [{tracer, test_tracer}]),
+ RootSpan1 = passage:set_baggage_items(
+ RootSpan0, fun () -> #{<<"foo">> => <<"bar">>} end),
+
+ ChildSpan0 = passage:start_span(child, [{child_of, RootSpan1}]),
+ ?assertEqual(#{<<"foo">> => <<"bar">>},
+ passage:get_baggage_items(ChildSpan0)),
+
+ ChildSpan1 = passage:set_baggage_items(
+ ChildSpan0, fun () -> #{<<"baz">> => <<"qux">>} end),
+ ?assertEqual(#{<<"foo">> => <<"bar">>, <<"baz">> => <<"qux">>},
+ passage:get_baggage_items(ChildSpan1))
+ end},
{"log",
fun () ->
ok = start_test_tracer(),
@@ -93,6 +122,20 @@
{#{hello := world}, {1, 2, 3}}],
passage_span:get_logs(FinishedSpan))
end},
+ {"log function",
+ fun () ->
+ ok = start_test_tracer(),
+ Span0 = passage:start_span(root, [{tracer, test_tracer}]),
+ Span1 = passage:log(Span0, fun () -> #{hello => world} end,
+ [{time, {1, 2, 3}}]),
+ Span2 = passage:log(Span1, fun () -> #{foo => bar} end),
+
+ passage:finish_span(Span2),
+ [FinishedSpan] = finished_spans(),
+ ?assertMatch([{#{foo := bar}, {_, _, _}},
+ {#{hello := world}, {1, 2, 3}}],
+ passage_span:get_logs(FinishedSpan))
+ end},
{"error log",
fun () ->
ok = start_test_tracer(),