Skip to content

Commit

Permalink
Merge pull request #301 from tsloughter/exporter-binary-string-host
Browse files Browse the repository at this point in the history
exporter: support hosts and paths as binary or list strings
  • Loading branch information
tsloughter authored Oct 28, 2021
2 parents 2170a84 + 9b25285 commit 2b6a188
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions apps/opentelemetry_exporter/src/opentelemetry_exporter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,23 @@ endpoint(Endpoint) ->
end.

parse_endpoint({Scheme, Host, Port, SSLOptions}) when is_list(SSLOptions) ->
{true, #{scheme => atom_to_list(Scheme), host => Host, port => Port, path => [], ssl_options => SSLOptions}};
{true, #{scheme => atom_to_list(Scheme),
host => unicode:characters_to_list(Host),
port => Port,
path => [],
ssl_options => SSLOptions}};
parse_endpoint({Scheme, Host, Port, _}) ->
{true, #{scheme => atom_to_list(Scheme), host => Host, port => Port, path => []}};
parse_endpoint(Endpoint=#{host := _Host, port := _Port, scheme := _Scheme, path := _Path}) ->
{true, Endpoint};
parse_endpoint(Endpoint=#{host := _Host, scheme := _Scheme, path := _Path}) ->
{true, Endpoint#{port => ?DEFAULT_PORT}};
{true, #{scheme => atom_to_list(Scheme),
host => unicode:characters_to_list(Host),
port => Port,
path => []}};
parse_endpoint(Endpoint=#{host := Host, port := _Port, scheme := _Scheme, path := Path}) ->
{true, Endpoint#{host => unicode:characters_to_list(Host),
path => unicode:characters_to_list(Path)}};
parse_endpoint(Endpoint=#{host := Host, scheme := _Scheme, path := Path}) ->
{true, Endpoint#{host => unicode:characters_to_list(Host),
port => ?DEFAULT_PORT,
path => unicode:characters_to_list(Path)}};
parse_endpoint(String) when is_list(String) orelse is_binary(String) ->
parse_endpoint(uri_string:parse(unicode:characters_to_list(String)));
parse_endpoint(_) ->
Expand Down

0 comments on commit 2b6a188

Please sign in to comment.