Skip to content

Commit

Permalink
Simplify test helper macro
Browse files Browse the repository at this point in the history
  • Loading branch information
nanodirijabl committed Jul 30, 2024
1 parent 0c463cd commit cd9974d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions apps/mg_core/src/mg_core_otel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ binary_to_id(Opaque) when is_binary(Opaque) ->
-type testgen() :: {_ID, fun(() -> _)}.
-spec test() -> _.

-define(IS_SAMPLED, 1).
-define(NOT_SAMPLED, 0).
-define(OTEL_CTX(IsSampled),
otel_tracer:set_current_span(
otel_ctx:new(),
Expand All @@ -196,19 +198,15 @@ binary_to_id(Opaque) when is_binary(Opaque) ->
is_valid = true,
is_remote = true,
is_recording = false,
trace_flags =
case IsSampled of
true -> 1;
false -> 0
end
trace_flags = IsSampled
}
)
).

-spec choose_viable_otel_ctx_test_() -> [testgen()].
choose_viable_otel_ctx_test_() ->
A = ?OTEL_CTX(true),
B = ?OTEL_CTX(false),
A = ?OTEL_CTX(?IS_SAMPLED),
B = ?OTEL_CTX(?NOT_SAMPLED),
[
?_assertEqual(A, choose_viable_otel_ctx(A, B)),
?_assertEqual(A, choose_viable_otel_ctx(B, A)),
Expand Down

0 comments on commit cd9974d

Please sign in to comment.