Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case for string list attr bug #736

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@
attributes = [{<<"attr-3">>, <<"value-3">>}]}], Events),
attributes = otel_attributes:new([{<<"attr-2">>, <<"value-2">>},
{attr_3, true},
{<<"map-key-1">>, #{<<"map-key-1">> => 123}},
{<<"list-key-1">>, [3.14, 9.345]}
{<<"map-key-1">>, #{<<"map-kv-1">> => 123}},
{<<"binary-list-key-1">>, [<<"value-1">>, <<"value-2">>]},
{<<"atom-list-key-1">>, [kv1, kv2]}
], 128, 128),
status = #status{code=?OTEL_STATUS_OK,
message = <<"">>},
Expand All @@ -327,6 +328,37 @@

PbSpan1 = maps:filter(fun(_, V) -> V =/= undefined end, PbSpan),
DecodedProto = opentelemetry_exporter_trace_service_pb:decode_msg(Proto, span),
% erlang:dump(DecodedProto),
ExpectedAttributes = [#{key => <<"map-key-1">>,
value =>
#{value =>
{kvlist_value,
#{values =>
[#{key => <<"map-kv-1">>,
value =>
#{value =>
{int_value,123}}}]}}}},
#{key => <<"binary-list-key-1">>,
value =>
#{value =>
{array_value,
#{values =>
[#{value => {string_value,<<"value-1">>}},
#{value =>
{string_value,<<"value-2">>}}]}}}},
#{key => <<"attr-2">>,
value => #{value => {string_value,<<"value-2">>}}},
#{key => <<"atom-list-key-1">>,
value =>
#{value =>
{array_value,
#{values =>
[#{value => {string_value,<<"value-1">>}},
#{value =>
{string_value,<<"value-2">>}}]}}}},
#{key => <<"attr_3">>,
value => #{value => {string_value,<<"true">>}}}],
?assertMatch(ExpectedAttributes, maps:get(attributes, DecodedProto)),

Check failure on line 361 in apps/opentelemetry_exporter/test/opentelemetry_exporter_SUITE.erl

View workflow job for this annotation

GitHub Actions / JUnit Test Report

/home/runner/work/opentelemetry-erlang/opentelemetry-erlang/apps/opentelemetry_exporter/test/opentelemetry_exporter_SUITE.erl.span_round_trip

Test span_round_trip in opentelemetry_exporter_SUITE failed!
Raw output
{{assertMatch,
     [{module,opentelemetry_exporter_SUITE},
      {line,361},
      {expression,"maps : get ( attributes , DecodedProto )"},
      {pattern,"ExpectedAttributes"},
      {value,
          [#{value =>
                 #{value =>
                       {kvlist_value,
                           #{values =>
                                 [#{value => #{value => {int_value,123}},
                                    key => <<"map-kv-1">>}]}}},
             key => <<"map-key-1">>},
           #{value =>
                 #{value =>
                       {array_value,
                           #{values =>
                                 [#{value => {string_value,<<"value-1">>}},
                                  #{value => {string_value,<<"value-2">>}}]}}},
             key => <<"binary-list-key-1">>},
           #{value => #{value => {string_value,<<"value-2">>}},
             key => <<"attr-2">>},
           #{value =>
                 #{value =>
                       {array_value,
                           #{values =>
                                 [#{value => {string_value,<<"kv1">>}},
                                  #{value => {string_value,<<"kv2">>}}]}}},
             key => <<"atom-list-key-1">>},
           #{value => #{value => {string_value,<<"true">>}},
             key => <<"attr_3">>}]}]},
 [{opentelemetry_exporter_SUITE,span_round_trip,1,
      [{file,
           "/home/runner/work/opentelemetry-erlang/opentelemetry-erlang/apps/opentelemetry_exporter/test/opentelemetry_exporter_SUITE.erl"},
       {line,361}]},
  {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
  {test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1302}]},
  {test_server,run_test_case_eval,9,[{file,"test_server.erl"},{line,1234}]}]}
?assertEqual(maps:with([trace_id, span_id], DecodedProto),
maps:with([trace_id, span_id], PbSpan1)),

Expand Down
39 changes: 39 additions & 0 deletions apps/opentelemetry_exporter/test/otel_otlp_common_SUITE.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-module(otel_otlp_common_SUITE).

-compile(export_all).
-compile(nowarn_export_all).

-include_lib("stdlib/include/assert.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("opentelemetry_api/include/opentelemetry.hrl").

all() ->
[
to_attrs_list_atoms,
to_attrs_list_binaries,
to_attrs_tuple_binaries
].


init_per_suite(Config) ->
Config.

end_per_suite(_Config) ->
ok.

to_attrs_list_atoms(_Config) ->
ArrayExpected = #{value => {array_value, #{values => [#{value => {string_value,<<"a">>}}, #{value => {string_value,<<"b">>}}]}}},
[#{value := Actual}] = otel_otlp_common:to_attributes(#{atoms => [a, b]}),
?assertEqual(ArrayExpected, Actual).


to_attrs_list_binaries(_Config) ->
ArrayExpected = #{value => {array_value, #{values => [#{value => {string_value,<<"a">>}}, #{value => {string_value,<<"b">>}}]}}},
[#{value := Actual}] = otel_otlp_common:to_attributes(#{atoms => [<<"a">>, <<"b">>]}),
?assertEqual(ArrayExpected, Actual).


to_attrs_tuple_binaries(_Config) ->
ArrayExpected = #{value => {array_value, #{values => [#{value => {string_value,<<"a">>}}, #{value => {string_value,<<"b">>}}]}}},
[#{value := Actual}] = otel_otlp_common:to_attributes(#{atoms => {<<"a">>, <<"b">>}}),
?assertEqual(ArrayExpected, Actual).
Loading