Skip to content

Commit e0e315b

Browse files
authored
Merge branch 'main' into test-link-event-attr
2 parents a3f5aaf + ccc6138 commit e0e315b

File tree

6 files changed

+33
-27
lines changed

6 files changed

+33
-27
lines changed

apps/opentelemetry/src/otel_events.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ new_event(#{system_time_nano := Timestamp,
8383
attributes=otel_attributes:new(Attributes, AttributePerEventLimit, AttributeValueLengthLimit)};
8484
new_event(#{name := Name,
8585
attributes := Attributes}, AttributePerEventLimit, AttributeValueLengthLimit) ->
86-
#event{system_time_nano=erlang:system_time(nanosecond),
86+
#event{system_time_nano=opentelemetry:timestamp(),
8787
name=Name,
8888
attributes=otel_attributes:new(Attributes, AttributePerEventLimit, AttributeValueLengthLimit)};
8989
new_event({Time, Name, Attributes}, AttributePerEventLimit, AttributeValueLengthLimit)

apps/opentelemetry/test/opentelemetry_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ update_span_data(Config) ->
377377
?set_current_span(SpanCtx1),
378378
?set_attribute(<<"key-1">>, <<"value-1">>),
379379

380-
Events = opentelemetry:events([{erlang:system_time(nanosecond),
380+
Events = opentelemetry:events([{opentelemetry:timestamp(),
381381
<<"event-name">>, []}]),
382382
Status = opentelemetry:status(0, <<"status">>),
383383

apps/opentelemetry_api/src/opentelemetry.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ link(_, _, _, _) ->
341341
Name :: event_name(),
342342
Attributes :: attributes_map().
343343
event(Name, Attributes) ->
344-
event(erlang:system_time(nanosecond), Name, Attributes).
344+
event(opentelemetry:timestamp(), Name, Attributes).
345345

346346
-spec event(Timestamp, Name, Attributes) -> event() | undefined when
347347
Timestamp :: non_neg_integer(),
@@ -362,7 +362,7 @@ event(_, _, _) ->
362362
undefined.
363363

364364
events(List) ->
365-
Now = erlang:system_time(nanosecond),
365+
Now = opentelemetry:timestamp(),
366366
lists:filtermap(fun({Time, Name, Attributes}) ->
367367
case event(Time, Name, Attributes) of
368368
undefined ->

apps/opentelemetry_exporter/src/opentelemetry_exporter.erl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,29 @@ parse_endpoint({Scheme, Host, Port, _}, DefaultSSLOpts) ->
278278
port => Port,
279279
path => [],
280280
ssl_options => update_ssl_opts(HostString, DefaultSSLOpts)}};
281-
parse_endpoint(Endpoint=#{host := Host, port := _Port, scheme := _Scheme, path := Path}, DefaultSSLOpts) ->
282-
HostString = unicode:characters_to_list(Host),
283-
{true, maps:merge(#{host => HostString,
284-
path => unicode:characters_to_list(Path),
285-
port => ?DEFAULT_PORT,
286-
ssl_options => update_ssl_opts(HostString, DefaultSSLOpts)}, Endpoint)};
287281
parse_endpoint(Endpoint=#{host := Host, scheme := _Scheme, path := Path}, DefaultSSLOpts) ->
288282
HostString = unicode:characters_to_list(Host),
289283
{true, maps:merge(#{host => unicode:characters_to_list(Host),
290284
port => ?DEFAULT_PORT,
291285
path => unicode:characters_to_list(Path),
292286
ssl_options => update_ssl_opts(HostString, DefaultSSLOpts)}, Endpoint)};
293287
parse_endpoint(String, DefaultSSLOpts) when is_list(String) orelse is_binary(String) ->
294-
parse_endpoint(uri_string:parse(unicode:characters_to_list(String)), DefaultSSLOpts);
288+
ParsedUri = maybe_add_scheme_port(uri_string:parse(unicode:characters_to_list(String))),
289+
parse_endpoint(ParsedUri, DefaultSSLOpts);
295290
parse_endpoint(_, _) ->
296291
false.
297292

293+
maybe_add_scheme_port(Uri=#{port := _Port}) ->
294+
Uri;
295+
maybe_add_scheme_port(Uri=#{scheme := "http"}) ->
296+
Uri#{port => 80};
297+
maybe_add_scheme_port(Uri=#{scheme := "https"}) ->
298+
Uri#{port => 443};
299+
%% an unknown scheme
300+
maybe_add_scheme_port(Uri) ->
301+
Uri.
302+
303+
298304
%% if no ssl opts are defined by the user then use defaults from `tls_certificate_check'
299305
update_ssl_opts(Host, undefined) ->
300306
tls_certificate_check:options(Host);

apps/opentelemetry_exporter/test/opentelemetry_exporter_SUITE.erl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ configuration(_Config) ->
7575
opentelemetry_exporter:endpoints(<<"https://localhost:443">>, [])),
7676

7777
?assertMatch([#{scheme := "https", host := "localhost", port := 443, path := "/used/path"}],
78-
opentelemetry_exporter:endpoints(<<"https://localhost:443/used/path">>, [])),
78+
opentelemetry_exporter:endpoints(<<"https://localhost/used/path">>, [])),
7979

80-
?assertMatch([#{scheme := "http", host := "localhost", port := 4318, path := []}],
80+
?assertMatch([#{scheme := "http", host := "localhost", port := 80, path := []}],
8181
opentelemetry_exporter:endpoints("http://localhost", [])),
8282

8383
?assertMatch([], opentelemetry_exporter:endpoints("://badendpoint", [])),
@@ -151,10 +151,10 @@ ets_instrumentation_info(_Config) ->
151151
start_time = opentelemetry:timestamp(),
152152
end_time = opentelemetry:timestamp(),
153153
links = otel_links:new([], 128, 128, 128),
154-
events = otel_events:add([#event{system_time_nano=erlang:system_time(nanosecond),
154+
events = otel_events:add([#event{system_time_nano=opentelemetry:timestamp(),
155155
name = <<"event-1">>,
156156
attributes = [{<<"attr-1">>, <<"value-1">>}]},
157-
#event{system_time_nano=erlang:system_time(nanosecond),
157+
#event{system_time_nano=opentelemetry:timestamp(),
158158
name = <<"event-2">>,
159159
attributes = [{<<"attr-3">>, <<"value-3">>}]}], Events1),
160160
attributes = otel_attributes:new([{<<"attr-2">>, <<"value-2">>}], 128, 128),
@@ -171,10 +171,10 @@ ets_instrumentation_info(_Config) ->
171171
start_time = opentelemetry:timestamp(),
172172
end_time = opentelemetry:timestamp(),
173173
links = otel_links:new([], 128, 128, 128),
174-
events = otel_events:add([#event{system_time_nano=erlang:system_time(nanosecond),
174+
events = otel_events:add([#event{system_time_nano=opentelemetry:timestamp(),
175175
name = <<"event-1">>,
176176
attributes = [{<<"attr-1">>, <<"value-1">>}]},
177-
#event{system_time_nano=erlang:system_time(nanosecond),
177+
#event{system_time_nano=opentelemetry:timestamp(),
178178
name = <<"event-2">>,
179179
attributes = [{<<"attr-3">>, <<"value-3">>}]}], Events2),
180180
attributes = otel_attributes:new([{<<"attr-2">>, <<"value-2">>}], 128, 128),
@@ -207,10 +207,10 @@ span_round_trip(_Config) ->
207207
start_time = opentelemetry:timestamp(),
208208
end_time = opentelemetry:timestamp(),
209209
links = otel_links:new([], 128, 128, 128),
210-
events = otel_events:add([#event{system_time_nano=erlang:system_time(nanosecond),
210+
events = otel_events:add([#event{system_time_nano=opentelemetry:timestamp(),
211211
name = <<"event-1">>,
212212
attributes = [{<<"attr-1">>, <<"value-1">>}]},
213-
#event{system_time_nano=erlang:system_time(nanosecond),
213+
#event{system_time_nano=opentelemetry:timestamp(),
214214
name = event_2,
215215
attributes = [{<<"attr-3">>, <<"value-3">>}]}], Events),
216216
attributes = otel_attributes:new([{<<"attr-2">>, <<"value-2">>},
@@ -268,10 +268,10 @@ verify_export(Config) ->
268268
start_time = opentelemetry:timestamp(),
269269
end_time = opentelemetry:timestamp(),
270270
links = otel_links:new([], 128, 128, 128),
271-
events = otel_events:add([#event{system_time_nano=erlang:system_time(nanosecond),
271+
events = otel_events:add([#event{system_time_nano=opentelemetry:timestamp(),
272272
name = <<"event-1">>,
273273
attributes = otel_attributes:new([{<<"attr-1">>, <<"value-1">>}], 128, 128)},
274-
#event{system_time_nano=erlang:system_time(nanosecond),
274+
#event{system_time_nano=opentelemetry:timestamp(),
275275
name = <<"event-2">>,
276276
attributes = otel_attributes:new([{<<"attr-3">>, <<"value-3">>}], 128, 128)}], Events),
277277
status = #status{code=?OTEL_STATUS_UNSET,
@@ -289,10 +289,10 @@ verify_export(Config) ->
289289
start_time = opentelemetry:timestamp(),
290290
end_time = opentelemetry:timestamp(),
291291
links = otel_links:new([Link1], 128, 128, 128),
292-
events = otel_events:add([#event{system_time_nano=erlang:system_time(nanosecond),
292+
events = otel_events:add([#event{system_time_nano=opentelemetry:timestamp(),
293293
name = <<"event-1">>,
294294
attributes = otel_attributes:new([{<<"attr-1">>, <<"value-1">>}], 128, 128)},
295-
#event{system_time_nano=erlang:system_time(nanosecond),
295+
#event{system_time_nano=opentelemetry:timestamp(),
296296
name = <<"event-2">>,
297297
attributes = otel_attributes:new([{<<"attr-3">>, <<"value-3">>}], 128, 128)}], Events),
298298
status = #status{code=?OTEL_STATUS_ERROR,

apps/opentelemetry_zipkin/test/opentelemetry_zipkin_SUITE.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ verify_export(_Config) ->
3232
kind = ?SPAN_KIND_CLIENT,
3333
start_time = opentelemetry:timestamp(),
3434
end_time = opentelemetry:timestamp(),
35-
events = [#event{system_time_nano=erlang:system_time(nanosecond),
35+
events = [#event{system_time_nano=opentelemetry:timestamp(),
3636
name = <<"event-1">>,
3737
attributes = [{<<"attr-1">>, <<"value-1">>}]},
38-
#event{system_time_nano=erlang:system_time(nanosecond),
38+
#event{system_time_nano=opentelemetry:timestamp(),
3939
name = <<"event-2">>,
4040
attributes = [{<<"attr-3">>, <<"value-3">>}]}],
4141
status=opentelemetry:status(?SPAN_KIND_INTERNAL, <<"some message about status">>),
@@ -49,10 +49,10 @@ verify_export(_Config) ->
4949
kind = ?SPAN_KIND_SERVER,
5050
start_time = opentelemetry:timestamp(),
5151
end_time = opentelemetry:timestamp(),
52-
events = [#event{system_time_nano=erlang:system_time(nanosecond),
52+
events = [#event{system_time_nano=opentelemetry:timestamp(),
5353
name = <<"event-1">>,
5454
attributes = [{<<"attr-1">>, <<"value-1">>}]},
55-
#event{system_time_nano=erlang:system_time(nanosecond),
55+
#event{system_time_nano=opentelemetry:timestamp(),
5656
name = <<"event-2">>,
5757
attributes = [{<<"attr-3">>, <<"value-3">>}]}],
5858
attributes = [{<<"attr-2">>, <<"value-2">>}]},

0 commit comments

Comments
 (0)