Otel 1.0.0-rc.4 updates (#54)

* Otel 1.0.0-rc.4 updates

* Unused module attribute

* Missed oban test
This commit is contained in:
Bryan Naegele 2021-12-28 16:39:06 -07:00 committed by GitHub
parent 4f087f85a5
commit 1d52d88e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 490 additions and 406 deletions

View File

@ -6,12 +6,19 @@ defmodule BasicElixir.Worker do
# Client # Client
def start_link(default) when is_list(default) do def start_link(default) when is_list(default) do
Tracer.with_span "start_link" do # Span names can be a binary or an atom. Atoms are preferred
Tracer.add_event("Nice operation!", [{"bogons", 100}]) # for memory efficiency.
Tracer.set_attributes([{:another_key, "yes"}]) Tracer.with_span :start_link do
# Span name rules also apply to events
Tracer.add_event("Nice operation!", %{"bogons" => 100})
Tracer.with_span "Sub operation..." do # Attributes can be a map or a keyword list
Tracer.set_attributes([{:lemons_key, "five"}]) Tracer.set_attributes(%{another_key: "yes"})
# Any attributes that can be known before starting a span
# should be passed on span creation so that they can be
# available for sampling decisions
Tracer.with_span "Sub operation...", %{attributes: [lemons_key: "five"]} do
Tracer.add_event("Sub span event!", []) Tracer.add_event("Sub span event!", [])
end end
@ -30,7 +37,7 @@ defmodule BasicElixir.Worker do
# Server (callbacks) # Server (callbacks)
@impl true @impl true
def init(stack) do def init(stack) do
Tracer.with_span "init" do Tracer.with_span :init do
Logger.info("Starting #{__MODULE__}...") Logger.info("Starting #{__MODULE__}...")
{:ok, stack} {:ok, stack}
end end

View File

@ -27,8 +27,8 @@ defmodule BasicElixir.MixProject do
# Run "mix help deps" to learn about dependencies. # Run "mix help deps" to learn about dependencies.
defp deps do defp deps do
[ [
{:opentelemetry, "~> 1.0.0-rc.3"}, {:opentelemetry, "~> 1.0.0-rc.4"},
{:opentelemetry_exporter, "~> 1.0.0-rc.3"}, {:opentelemetry_exporter, "~> 1.0.0-rc.4"}
] ]
end end
end end

View File

@ -0,0 +1,7 @@
# Changelog
## Unreleased
### Changed
* Opentelemetry 1.0.0-rc.4 support

View File

@ -1,7 +1,8 @@
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{deps, [ {deps, [
{opentelemetry_api, "~> 1.0.0-rc.3"}, {cowboy_telemetry, "~> 0.4"},
{opentelemetry_telemetry, "~> 1.0.0-beta.4"}, {opentelemetry_api, "~> 1.0.0-rc.4"},
{opentelemetry_telemetry, "~> 1.0.0-beta.6"},
{telemetry, "~> 1.0"} {telemetry, "~> 1.0"}
]}. ]}.
@ -17,10 +18,9 @@
{subpackages, true}]}]}, {subpackages, true}]}]},
{test, [{erl_opts, [nowarn_export_all]}, {test, [{erl_opts, [nowarn_export_all]},
{deps, [ {deps, [
{opentelemetry, "~> 1.0.0-rc.3"}, {opentelemetry, "~> 1.0.0-rc.4"},
{opentelemetry_exporter, "~> 1.0.0-rc.3"}, {opentelemetry_exporter, "~> 1.0.0-rc.4"},
{cowboy, "~> 2.7"}, {cowboy, "~> 2.7"}
{cowboy_telemetry, "~> 0.4"}
]}, ]},
{paths, ["src", "test/support"]}, {paths, ["src", "test/support"]},
{ct_opts, [{ct_hooks, [cth_surefire]}]}]}]}. {ct_opts, [{ct_hooks, [cth_surefire]}]}]}]}.

View File

@ -1,19 +1,31 @@
{"1.2.0", {"1.2.0",
[{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.0.0-rc.3.2">>},0}, [{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},1},
{<<"cowboy_telemetry">>,{pkg,<<"cowboy_telemetry">>,<<"0.4.0">>},0},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},2},
{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.0.0-rc.4">>},0},
{<<"opentelemetry_telemetry">>, {<<"opentelemetry_telemetry">>,
{pkg,<<"opentelemetry_telemetry">>,<<"1.0.0-beta.4">>}, {pkg,<<"opentelemetry_telemetry">>,<<"1.0.0-beta.6.1">>},
0}, 0},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2},
{<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.0.0">>},0}, {<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.0.0">>},0},
{<<"telemetry_registry">>,{pkg,<<"telemetry_registry">>,<<"0.3.0">>},1}]}. {<<"telemetry_registry">>,{pkg,<<"telemetry_registry">>,<<"0.3.0">>},1}]}.
[ [
{pkg_hash,[ {pkg_hash,[
{<<"opentelemetry_api">>, <<"588EBF85FA7D18EBA8DB297B7D0A2A654F680F35C4466CD0045CD12A6FDA27D7">>}, {<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>},
{<<"opentelemetry_telemetry">>, <<"74B2A9DE1B2F1C22955A2FA3263D65A979FD64BF69D3D1571B5C34FDFED95CFA">>}, {<<"cowboy_telemetry">>, <<"F239F68B588EFA7707ABCE16A84D0D2ACF3A0F50571F8BB7F56A15865AAE820C">>},
{<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>},
{<<"opentelemetry_api">>, <<"13FB20B8800149CE52DAA8FB793C1A45B826CC4BD0D5BC7E8A00CAB46285CBE6">>},
{<<"opentelemetry_telemetry">>, <<"CB8B9E0CC1E740D7FEDCB2F60498877A7593B1E46932076AAC9B58708C64763E">>},
{<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>},
{<<"telemetry">>, <<"0F453A102CDF13D506B7C0AB158324C337C41F1CC7548F0BC0E130BBF0AE9452">>}, {<<"telemetry">>, <<"0F453A102CDF13D506B7C0AB158324C337C41F1CC7548F0BC0E130BBF0AE9452">>},
{<<"telemetry_registry">>, <<"6768F151EA53FC0FBCA70DBFF5B20A8D663EE4E0C0B2AE589590E08658E76F1E">>}]}, {<<"telemetry_registry">>, <<"6768F151EA53FC0FBCA70DBFF5B20A8D663EE4E0C0B2AE589590E08658E76F1E">>}]},
{pkg_hash_ext,[ {pkg_hash_ext,[
{<<"opentelemetry_api">>, <<"1E0BA55DB6718D5797E72C00E3821E60E02F7829E3FB64DC1A7C96F7C2776A58">>}, {<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>},
{<<"opentelemetry_telemetry">>, <<"6EBBA3C47A26460A7302BFCDCCF87582EEB1A71C2E6ABC47845787DCD04FB256">>}, {<<"cowboy_telemetry">>, <<"7D98BAC1EE4565D31B62D59F8823DFD8356A169E7FCBB83831B8A5397404C9DE">>},
{<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>},
{<<"opentelemetry_api">>, <<"29C5BF7D5C40C4B9816906277BEB2438E6737073721C75398465B1ACD1B56B06">>},
{<<"opentelemetry_telemetry">>, <<"6BE70F51CD519EC225EED6018B747AAA7FB3176460669D7E9776745FF48753AC">>},
{<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>},
{<<"telemetry">>, <<"73BC09FA59B4A0284EFB4624335583C528E07EC9AE76ACA96EA0673850AEC57A">>}, {<<"telemetry">>, <<"73BC09FA59B4A0284EFB4624335583C528E07EC9AE76ACA96EA0673850AEC57A">>},
{<<"telemetry_registry">>, <<"492E2ADBC609F3E79ECE7F29FEC363A97A2C484AC78A83098535D6564781E917">>}]} {<<"telemetry_registry">>, <<"492E2ADBC609F3E79ECE7F29FEC363A97A2C484AC78A83098535D6564781E917">>}]}
]. ].

View File

@ -1,6 +1,6 @@
{application, opentelemetry_cowboy, {application, opentelemetry_cowboy,
[{description, "OpenTelemetry Cowboy Instrumentation"}, [{description, "OpenTelemetry Cowboy Instrumentation"},
{vsn, "0.1.0"}, {vsn, "0.2.0"},
{registered, []}, {registered, []},
{applications, {applications,
[kernel, [kernel,

View File

@ -7,7 +7,7 @@
-include_lib("opentelemetry_api/include/opentelemetry.hrl"). -include_lib("opentelemetry_api/include/opentelemetry.hrl").
-define(TRACER_ID, opentelemetry_cowboy). -define(TRACER_ID, ?MODULE).
-spec setup() -> ok. -spec setup() -> ok.
setup() -> setup() ->
@ -33,40 +33,39 @@ handle_event([cowboy, request, start], _Measurements, #{req := Req} = Meta, _Con
{RemoteIP, _Port} = maps:get(peer, Req), {RemoteIP, _Port} = maps:get(peer, Req),
Method = maps:get(method, Req), Method = maps:get(method, Req),
Attributes = [ Attributes = #{
{'http.client_ip', client_ip(Headers, RemoteIP)}, 'http.client_ip' => client_ip(Headers, RemoteIP),
{'http.flavor', http_flavor(Req)}, 'http.flavor' => http_flavor(Req),
{'http.host', maps:get(host, Req)}, 'http.host' => maps:get(host, Req),
{'http.host.port', maps:get(port, Req)}, 'http.host.port' => maps:get(port, Req),
{'http.method', Method}, 'http.method' => Method,
{'http.scheme', maps:get(scheme, Req)}, 'http.scheme' => maps:get(scheme, Req),
{'http.target', maps:get(path, Req)}, 'http.target' => maps:get(path, Req),
{'http.user_agent', maps:get(<<"user-agent">>, Headers, <<"">>)}, 'http.user_agent' => maps:get(<<"user-agent">>, Headers, <<"">>),
{'net.host.ip', iolist_to_binary(inet:ntoa(RemoteIP))}, 'net.host.ip' => iolist_to_binary(inet:ntoa(RemoteIP)),
{'net.transport', 'IP.TCP'} 'net.transport' => 'IP.TCP'
], },
SpanName = iolist_to_binary([<<"HTTP ">>, Method]), SpanName = iolist_to_binary([<<"HTTP ">>, Method]),
Ctx = otel_telemetry:start_telemetry_span(?TRACER_ID, SpanName, Meta, #{}), otel_telemetry:start_telemetry_span(?TRACER_ID, SpanName, Meta, #{attributes => Attributes});
otel_span:set_attributes(Ctx, Attributes);
handle_event([cowboy, request, stop], Measurements, Meta, _Config) -> handle_event([cowboy, request, stop], Measurements, Meta, _Config) ->
Ctx = otel_telemetry:set_current_telemetry_span(?TRACER_ID, Meta), Ctx = otel_telemetry:set_current_telemetry_span(?TRACER_ID, Meta),
Status = maps:get(resp_status, Meta), Status = maps:get(resp_status, Meta),
Attributes = [ Attributes = #{
{'http.request_content_length', maps:get(req_body_length, Measurements)}, 'http.request_content_length' => maps:get(req_body_length, Measurements),
{'http.response_content_length', maps:get(resp_body_length, Measurements)} 'http.response_content_length' => maps:get(resp_body_length, Measurements)
], },
otel_span:set_attributes(Ctx, Attributes), otel_span:set_attributes(Ctx, Attributes),
case Status of case Status of
undefined -> undefined ->
{ErrorType, Error, Reason} = maps:get(error, Meta), {ErrorType, Error, Reason} = maps:get(error, Meta),
otel_span:add_event(Ctx, atom_to_binary(ErrorType, utf8), [{error, Error}, {reason, Reason}]), otel_span:add_events(Ctx, [opentelemetry:event(ErrorType, #{error => Error, reason => Reason})]),
otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, Reason)); otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, Reason));
Status when Status >= 400 -> Status when Status >= 400 ->
otel_span:set_attributes(Ctx, [{'http.status', Status}]), otel_span:set_attribute(Ctx, 'http.status', Status),
otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, <<"">>)); otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, <<"">>));
Status when Status < 400 -> Status when Status < 400 ->
otel_span:set_attributes(Ctx, [{'http.status', Status}]) otel_span:set_attribute(Ctx, 'http.status', Status)
end, end,
otel_telemetry:end_telemetry_span(?TRACER_ID, Meta), otel_telemetry:end_telemetry_span(?TRACER_ID, Meta),
otel_ctx:clear(); otel_ctx:clear();
@ -81,26 +80,25 @@ handle_event([cowboy, request, exception], Measurements, Meta, _Config) ->
} = Meta, } = Meta,
otel_span:record_exception(Ctx, Kind, Reason, Stacktrace, []), otel_span:record_exception(Ctx, Kind, Reason, Stacktrace, []),
otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, <<"">>)), otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, <<"">>)),
otel_span:set_attributes(Ctx, [ otel_span:set_attributes(Ctx, #{
{'http.status', Status}, 'http.status' => Status,
{'http.request_content_length', maps:get(req_body_length, Measurements)}, 'http.request_content_length' => maps:get(req_body_length, Measurements),
{'http.response_content_length', maps:get(resp_body_length, Measurements)} 'http.response_content_length' => maps:get(resp_body_length, Measurements)
]), }),
otel_telemetry:end_telemetry_span(?TRACER_ID, Meta), otel_telemetry:end_telemetry_span(?TRACER_ID, Meta),
otel_ctx:clear(); otel_ctx:clear();
handle_event([cowboy, request, early_error], Measurements, Meta, _Config) -> handle_event([cowboy, request, early_error], Measurements, Meta, _Config) ->
Ctx = otel_telemetry:start_telemetry_span(?TRACER_ID, <<"HTTP Error">>, Meta, #{}),
#{ #{
reason := {ErrorType, Error, Reason}, reason := {ErrorType, Error, Reason},
resp_status := Status resp_status := Status
} = Meta, } = Meta,
Attributes = #{
otel_span:set_attributes(Ctx, [ 'http.status' => Status,
{'http.status', Status}, 'http.response_content_length' => maps:get(resp_body_length, Measurements)
{'http.response_content_length', maps:get(resp_body_length, Measurements)} },
]), Ctx = otel_telemetry:start_telemetry_span(?TRACER_ID, <<"HTTP Error">>, Meta, #{attributes => Attributes}),
otel_span:add_event(Ctx, atom_to_binary(ErrorType, utf8), [{error, Error}, {reason, Reason}]), otel_span:add_events(Ctx, [opentelemetry:event(ErrorType, #{error => Error, reason => Reason})]),
otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, Reason)), otel_span:set_status(Ctx, opentelemetry:status(?OTEL_STATUS_ERROR, Reason)),
otel_telemetry:end_telemetry_span(?TRACER_ID, Meta), otel_telemetry:end_telemetry_span(?TRACER_ID, Meta),
otel_ctx:clear(). otel_ctx:clear().

View File

@ -59,11 +59,6 @@ init_per_testcase(_, Config) ->
Config. Config.
end_per_testcase(_, Config) -> end_per_testcase(_, Config) ->
application:stop(telemetry),
application:stop(opentelemetry_cowboy),
application:stop(opentelemetry_telemetry),
application:stop(opentelemetry),
Config. Config.
successful_request(_Config) -> successful_request(_Config) ->
@ -75,24 +70,24 @@ successful_request(_Config) ->
{ok, {{_Version, 200, _ReasonPhrase}, _Headers, _Body}} = {ok, {{_Version, 200, _ReasonPhrase}, _Headers, _Body}} =
httpc:request(get, {"http://localhost:8080/success", Headers}, [], []), httpc:request(get, {"http://localhost:8080/success", Headers}, [], []),
receive receive
{span, #span{name=Name,events=[],attributes=Attributes,parent_span_id=ParentSpanId}} -> {span, #span{name=Name,attributes=Attributes,parent_span_id=ParentSpanId}} ->
?assertEqual(<<"HTTP GET">>, Name), ?assertEqual(<<"HTTP GET">>, Name),
?assertEqual(13235353014750950193, ParentSpanId), ?assertEqual(13235353014750950193, ParentSpanId),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.client_ip', <<"203.0.133.195">>}, 'http.client_ip' => <<"203.0.133.195">>,
{'http.flavor', '1.1'}, 'http.flavor' => '1.1',
{'http.host', <<"localhost">>}, 'http.host' => <<"localhost">>,
{'http.host.port', 8080}, 'http.host.port' => 8080,
{'http.method', <<"GET">>}, 'http.method' => <<"GET">>,
{'http.scheme', <<"http">>}, 'http.scheme' => <<"http">>,
{'http.target', <<"/success">>}, 'http.target' => <<"/success">>,
{'http.user_agent', <<"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0">>}, 'http.user_agent' => <<"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0">>,
{'net.host.ip', <<"127.0.0.1">>}, 'net.host.ip' => <<"127.0.0.1">>,
{'net.transport', 'IP.TCP'}, 'net.transport' => 'IP.TCP',
{'http.status', 200}, 'http.status' => 200,
{'http.request_content_length', 0}, 'http.request_content_length' => 0,
{'http.response_content_length', 12}], 'http.response_content_length' => 12},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(successful_request) 1000 -> ct:fail(successful_request)
end. end.
@ -101,23 +96,23 @@ chunked_request(_Config) ->
{ok, {{_Version, 200, _ReasonPhrase}, _Headers, _Body}} = {ok, {{_Version, 200, _ReasonPhrase}, _Headers, _Body}} =
httpc:request(get, {"http://localhost:8080/chunked", []}, [], []), httpc:request(get, {"http://localhost:8080/chunked", []}, [], []),
receive receive
{span, #span{name=Name,events=[],attributes=Attributes,parent_span_id=undefined}} -> {span, #span{name=Name,attributes=Attributes,parent_span_id=undefined}} ->
?assertEqual(<<"HTTP GET">>, Name), ?assertEqual(<<"HTTP GET">>, Name),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.client_ip', <<"127.0.0.1">>}, 'http.client_ip' => <<"127.0.0.1">>,
{'http.flavor', '1.1'}, 'http.flavor' => '1.1',
{'http.host', <<"localhost">>}, 'http.host' => <<"localhost">>,
{'http.host.port', 8080}, 'http.host.port' => 8080,
{'http.method', <<"GET">>}, 'http.method' => <<"GET">>,
{'http.scheme', <<"http">>}, 'http.scheme' => <<"http">>,
{'http.target', <<"/chunked">>}, 'http.target' => <<"/chunked">>,
{'http.user_agent', <<>>}, 'http.user_agent' => <<>>,
{'net.host.ip', <<"127.0.0.1">>}, 'net.host.ip' => <<"127.0.0.1">>,
{'net.transport', 'IP.TCP'}, 'net.transport' => 'IP.TCP',
{'http.status', 200}, 'http.status' => 200,
{'http.request_content_length', 0}, 'http.request_content_length' => 0,
{'http.response_content_length', 14}], 'http.response_content_length' => 14},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(chunked_request) 1000 -> ct:fail(chunked_request)
end. end.
@ -126,28 +121,25 @@ failed_request(_Config) ->
{ok, {{_Version, 500, _ReasonPhrase}, _Headers, _Body}} = {ok, {{_Version, 500, _ReasonPhrase}, _Headers, _Body}} =
httpc:request(get, {"http://localhost:8080/failure", []}, [], []), httpc:request(get, {"http://localhost:8080/failure", []}, [], []),
receive receive
{span, #span{name=Name,events=[Event],attributes=Attributes,parent_span_id=undefined}} -> {span, #span{name=Name,events=Events,attributes=Attributes,parent_span_id=undefined}} ->
{ [Event] = otel_events:list(Events),
event,_,<<"exception">>,[ #event{name= <<"exception">>} = Event,
{<<"exception.type">>, <<"exit:failure">>},
{<<"exception.stacktrace">>, _Stacktrace}]
} = Event,
?assertEqual(<<"HTTP GET">>, Name), ?assertEqual(<<"HTTP GET">>, Name),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.client_ip', <<"127.0.0.1">>}, 'http.client_ip' => <<"127.0.0.1">>,
{'http.flavor', '1.1'}, 'http.flavor' => '1.1',
{'http.host', <<"localhost">>}, 'http.host' => <<"localhost">>,
{'http.host.port', 8080}, 'http.host.port' => 8080,
{'http.method', <<"GET">>}, 'http.method' => <<"GET">>,
{'http.scheme', <<"http">>}, 'http.scheme' => <<"http">>,
{'http.target', <<"/failure">>}, 'http.target' => <<"/failure">>,
{'http.user_agent', <<>>}, 'http.user_agent' => <<>>,
{'net.host.ip', <<"127.0.0.1">>}, 'net.host.ip' => <<"127.0.0.1">>,
{'net.transport', 'IP.TCP'}, 'net.transport' => 'IP.TCP',
{'http.status', 500}, 'http.status' => 500,
{'http.request_content_length', 0}, 'http.request_content_length' => 0,
{'http.response_content_length', 0}], 'http.response_content_length' => 0},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(failed_request) 1000 -> ct:fail(failed_request)
end. end.
@ -156,27 +148,29 @@ client_timeout_request(_Config) ->
{error, timeout} = {error, timeout} =
httpc:request(get, {"http://localhost:8080/slow", []}, [{timeout, 50}], []), httpc:request(get, {"http://localhost:8080/slow", []}, [{timeout, 50}], []),
receive receive
{span, #span{name=Name,events=[Event],attributes=Attributes,parent_span_id=undefined}} -> {span, #span{name=Name,events=Events,attributes=Attributes,parent_span_id=undefined}} ->
{ [Event] = otel_events:list(Events),
event,_,<<"socket_error">>,[ #event{name='socket_error',attributes = EventAttributes} = Event,
{error, closed}, ExpectedEventAttrs = #{
{reason, 'The socket has been closed.'}] error => closed,
} = Event, reason => 'The socket has been closed.'
},
?assertMatch(ExpectedEventAttrs, otel_attributes:map(EventAttributes)),
?assertEqual(<<"HTTP GET">>, Name), ?assertEqual(<<"HTTP GET">>, Name),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.client_ip', <<"127.0.0.1">>}, 'http.client_ip' => <<"127.0.0.1">>,
{'http.flavor', '1.1'}, 'http.flavor' => '1.1',
{'http.host', <<"localhost">>}, 'http.host' => <<"localhost">>,
{'http.host.port', 8080}, 'http.host.port' => 8080,
{'http.method', <<"GET">>}, 'http.method' => <<"GET">>,
{'http.scheme', <<"http">>}, 'http.scheme' => <<"http">>,
{'http.target', <<"/slow">>}, 'http.target' => <<"/slow">>,
{'http.user_agent', <<>>}, 'http.user_agent' => <<>>,
{'net.host.ip', <<"127.0.0.1">>}, 'net.host.ip' => <<"127.0.0.1">>,
{'net.transport', 'IP.TCP'}, 'net.transport' => 'IP.TCP',
{'http.request_content_length', 0}, 'http.request_content_length' => 0,
{'http.response_content_length', 0}], 'http.response_content_length' => 0},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(client_timeout_request) 1000 -> ct:fail(client_timeout_request)
end. end.
@ -185,27 +179,29 @@ idle_timeout_request(_Config) ->
{error, socket_closed_remotely} = {error, socket_closed_remotely} =
httpc:request(head, {"http://localhost:8080/slow", []}, [], []), httpc:request(head, {"http://localhost:8080/slow", []}, [], []),
receive receive
{span, #span{name=Name,events=[Event],attributes=Attributes,parent_span_id=undefined}} -> {span, #span{name=Name,events=Events,attributes=Attributes,parent_span_id=undefined}} ->
{ [Event] = otel_events:list(Events),
event,_,<<"connection_error">>,[ #event{name= 'connection_error',attributes = EventAttributes} = Event,
{error, timeout}, ExpectedEventAttrs = #{
{reason, 'Connection idle longer than configuration allows.'}] error => timeout,
} = Event, reason => 'Connection idle longer than configuration allows.'
},
?assertMatch(ExpectedEventAttrs, otel_attributes:map(EventAttributes)),
?assertEqual(<<"HTTP HEAD">>, Name), ?assertEqual(<<"HTTP HEAD">>, Name),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.client_ip', <<"127.0.0.1">>}, 'http.client_ip' => <<"127.0.0.1">>,
{'http.flavor', '1.1'}, 'http.flavor' => '1.1',
{'http.host', <<"localhost">>}, 'http.host' => <<"localhost">>,
{'http.host.port', 8080}, 'http.host.port' => 8080,
{'http.method', <<"HEAD">>}, 'http.method' => <<"HEAD">>,
{'http.scheme', <<"http">>}, 'http.scheme' => <<"http">>,
{'http.target', <<"/slow">>}, 'http.target' => <<"/slow">>,
{'http.user_agent', <<>>}, 'http.user_agent' => <<>>,
{'net.host.ip', <<"127.0.0.1">>}, 'net.host.ip' => <<"127.0.0.1">>,
{'net.transport', 'IP.TCP'}, 'net.transport' => 'IP.TCP',
{'http.request_content_length', 0}, 'http.request_content_length' => 0,
{'http.response_content_length', 0}], 'http.response_content_length' => 0},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(idle_timeout_request) 1000 -> ct:fail(idle_timeout_request)
end. end.
@ -213,23 +209,23 @@ idle_timeout_request(_Config) ->
chunk_timeout_request(_Config) -> chunk_timeout_request(_Config) ->
httpc:request(head, {"http://localhost:8080/chunked_slow", []}, [], []), httpc:request(head, {"http://localhost:8080/chunked_slow", []}, [], []),
receive receive
{span, #span{name=Name,events=[],attributes=Attributes,parent_span_id=undefined}} -> {span, #span{name=Name,attributes=Attributes,parent_span_id=undefined}} ->
?assertEqual(<<"HTTP HEAD">>, Name), ?assertEqual(<<"HTTP HEAD">>, Name),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.client_ip', <<"127.0.0.1">>}, 'http.client_ip' => <<"127.0.0.1">>,
{'http.flavor', '1.1'}, 'http.flavor' => '1.1',
{'http.host', <<"localhost">>}, 'http.host' => <<"localhost">>,
{'http.host.port', 8080}, 'http.host.port' => 8080,
{'http.method', <<"HEAD">>}, 'http.method' => <<"HEAD">>,
{'http.scheme', <<"http">>}, 'http.scheme' => <<"http">>,
{'http.target', <<"/chunked_slow">>}, 'http.target' => <<"/chunked_slow">>,
{'http.user_agent', <<>>}, 'http.user_agent' => <<>>,
{'net.host.ip', <<"127.0.0.1">>}, 'net.host.ip' => <<"127.0.0.1">>,
{'net.transport', 'IP.TCP'}, 'net.transport' => 'IP.TCP',
{'http.status',200}, 'http.status' => 200,
{'http.request_content_length', 0}, 'http.request_content_length' => 0,
{'http.response_content_length', 0}], 'http.response_content_length' => 0},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(chunk_timeout_request) 1000 -> ct:fail(chunk_timeout_request)
end. end.
@ -242,17 +238,19 @@ bad_request(_Config) ->
{ok, {{_Version, 501, _ReasonPhrase}, _Headers, _Body}} = {ok, {{_Version, 501, _ReasonPhrase}, _Headers, _Body}} =
httpc:request(trace, {"http://localhost:8080/", Headers}, [], []), httpc:request(trace, {"http://localhost:8080/", Headers}, [], []),
receive receive
{span, #span{name=Name,events=[Event],attributes=Attributes,parent_span_id=undefined}} -> {span, #span{name=Name,events=Events,attributes=Attributes,parent_span_id=undefined}} ->
{ [Event] = otel_events:list(Events),
event,_,<<"connection_error">>,[ #event{name='connection_error',attributes = EventAttributes} = Event,
{error, no_error}, ExpectedEventAttrs = #{
{reason, 'The TRACE method is currently not implemented. (RFC7231 4.3.8)'}] error => no_error,
} = Event, reason => 'The TRACE method is currently not implemented. (RFC7231 4.3.8)'
},
?assertMatch(ExpectedEventAttrs, otel_attributes:map(EventAttributes)),
?assertEqual(<<"HTTP Error">>, Name), ?assertEqual(<<"HTTP Error">>, Name),
ExpectedAttrs = [ ExpectedAttrs = #{
{'http.status', 501}, 'http.status' => 501,
{'http.response_content_length', 0}], 'http.response_content_length' => 0},
?assertListsMatch(ExpectedAttrs, Attributes) ?assertMatch(ExpectedAttrs, otel_attributes:map(Attributes))
after after
1000 -> ct:fail(bad_request) 1000 -> ct:fail(bad_request)
end. end.

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 1.0.0-rc.4
### Changed
* Opentelemetry 1.0.0-rc.4 support
## 1.0.0-rc.2 ## 1.0.0-rc.2
### Changed ### Changed

View File

@ -23,7 +23,7 @@ by adding `opentelemetry_ecto` to your list of dependencies in `mix.exs`:
```elixir ```elixir
def deps do def deps do
[ [
{:opentelemetry_ecto, "~> 1.0.0-rc.2"} {:opentelemetry_ecto, "~> 1.0.0-rc.4"}
] ]
end end
``` ```
@ -37,6 +37,7 @@ end
| v1.0.0-rc.1 | v1.0.0-rc.1 | | | v1.0.0-rc.1 | v1.0.0-rc.1 | |
| v1.0.0-rc.2 | v1.0.0-rc.2 | | | v1.0.0-rc.2 | v1.0.0-rc.2 | |
| v1.0.0-rc.3 | v1.0.0-rc.3 | | | v1.0.0-rc.3 | v1.0.0-rc.3 | |
| v1.0.0-rc.4 | v1.0.0-rc.4 | |
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can and published on [HexDocs](https://hexdocs.pm). Once published, the docs can

View File

@ -1,6 +1,6 @@
# This file is responsible for configuring your application # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module. # and its dependencies with the aid of the Mix.Config module.
use Mix.Config import Config
# This configuration is loaded before any dependency and is restricted # This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this # to this project. If another project depends on this project, this

View File

@ -69,28 +69,29 @@ defmodule OpentelemetryEcto do
# TODO: need connection information to complete the required attributes # TODO: need connection information to complete the required attributes
# net.peer.name or net.peer.ip and net.peer.port # net.peer.name or net.peer.ip and net.peer.port
base_attributes = [ base_attributes = %{
"db.type": db_type, "db.type": db_type,
"db.statement": query, "db.statement": query,
source: source, source: source,
"db.instance": database, "db.instance": database,
"db.url": url, "db.url": url,
"total_time_#{time_unit}s": System.convert_time_unit(total_time, :native, time_unit) "total_time_#{time_unit}s": System.convert_time_unit(total_time, :native, time_unit)
] }
attributes = attributes =
measurements measurements
|> Enum.into(%{}) |> Enum.reduce(%{}, fn
|> Map.take(~w(decode_time query_time queue_time)a) {k, v}, acc when not is_nil(v) and k in [:decode_time, :query_time, :queue_time] ->
|> Enum.reject(&is_nil(elem(&1, 1))) Map.put(acc, String.to_atom("#{k}_#{time_unit}s"), System.convert_time_unit(v, :native, time_unit))
|> Enum.map(fn {k, v} ->
{String.to_atom("#{k}_#{time_unit}s"), System.convert_time_unit(v, :native, time_unit)} _, acc ->
acc
end) end)
s = s =
OpenTelemetry.Tracer.start_span(span_name, %{ OpenTelemetry.Tracer.start_span(span_name, %{
start_time: start_time, start_time: start_time,
attributes: attributes ++ base_attributes, attributes: Map.merge(attributes, base_attributes),
kind: :client kind: :client
}) })

View File

@ -5,7 +5,7 @@ defmodule OpentelemetryEcto.MixProject do
[ [
app: :opentelemetry_ecto, app: :opentelemetry_ecto,
description: description(), description: description(),
version: "1.0.0-rc.3", version: "1.0.0-rc.4",
elixir: "~> 1.10", elixir: "~> 1.10",
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
deps: deps(), deps: deps(),
@ -24,7 +24,7 @@ defmodule OpentelemetryEcto.MixProject do
defp package do defp package do
[ [
files: ~w(lib .formatter.exs mix.exs README* LICENSE* CHANGELOG*), files: ~w(lib .formatter.exs mix.exs README* LICENSE* CHANGELOG*),
licenses: ["Apache-2"], licenses: ["Apache-2.0"],
links: %{ links: %{
"GitHub" => "GitHub" =>
"https://github.com/open-telemetry/opentelemetry-erlang-contrib/tree/main/instrumentation/opentelemetry_ecto", "https://github.com/open-telemetry/opentelemetry-erlang-contrib/tree/main/instrumentation/opentelemetry_ecto",
@ -49,12 +49,13 @@ defmodule OpentelemetryEcto.MixProject do
defp deps do defp deps do
[ [
{:telemetry, "~> 0.4 or ~> 1.0.0"}, {:telemetry, "~> 0.4 or ~> 1.0.0"},
{:opentelemetry_api, "~> 1.0.0-rc.3"}, {:opentelemetry_api, "~> 1.0.0-rc.4"},
{:opentelemetry, "~> 1.0.0-rc.3", only: [:dev, :test]}, {:opentelemetry, "~> 1.0.0-rc.4", only: [:dev, :test]},
{:opentelemetry_exporter, "~> 1.0.0-rc.3", only: [:dev, :test]}, {:opentelemetry_exporter, "~> 1.0.0-rc.4", only: [:dev, :test]},
{:ex_doc, "~> 0.25.0", only: [:dev], runtime: false}, {:ex_doc, "~> 0.26.0", only: [:dev], runtime: false},
{:ecto_sql, ">= 3.0.0", only: [:dev, :test]}, {:ecto_sql, ">= 3.0.0", only: [:dev, :test]},
{:postgrex, ">= 0.15.0", only: [:dev, :test]} {:postgrex, ">= 0.15.0", only: [:dev, :test]},
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false}
] ]
end end
end end

View File

@ -3,23 +3,27 @@
"chatterbox": {:hex, :ts_chatterbox, "0.11.0", "b8f372c706023eb0de5bf2976764edb27c70fe67052c88c1f6a66b3a5626847f", [:rebar3], [{:hpack, "~>0.2.3", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "722fe2bad52913ab7e87d849fc6370375f0c961ffb2f0b5e6d647c9170c382a6"}, "chatterbox": {:hex, :ts_chatterbox, "0.11.0", "b8f372c706023eb0de5bf2976764edb27c70fe67052c88c1f6a66b3a5626847f", [:rebar3], [{:hpack, "~>0.2.3", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "722fe2bad52913ab7e87d849fc6370375f0c961ffb2f0b5e6d647c9170c382a6"},
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
"ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"}, "ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"},
"db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"}, "db_connection": {:hex, :db_connection, "2.4.1", "6411f6e23f1a8b68a82fa3a36366d4881f21f47fc79a9efb8c615e62050219da", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ea36d226ec5999781a9a8ad64e5d8c4454ecedc7a4d643e4832bf08efca01f00"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"}, "earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"},
"earmark_parser": {:hex, :earmark_parser, "1.4.16", "607709303e1d4e3e02f1444df0c821529af1c03b8578dfc81bb9cf64553d02b9", [:mix], [], "hexpm", "69fcf696168f5a274dd012e3e305027010658b2d1630cef68421d6baaeaccead"}, "earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"},
"ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"}, "ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"},
"ecto_sql": {:hex, :ecto_sql, "3.7.1", "8de624ef50b2a8540252d8c60506379fbbc2707be1606853df371cf53df5d053", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2b42a32e2ce92f64aba5c88617891ab3b0ba34f3f3a503fa20009eae1a401c81"}, "ecto_sql": {:hex, :ecto_sql, "3.7.1", "8de624ef50b2a8540252d8c60506379fbbc2707be1606853df371cf53df5d053", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2b42a32e2ce92f64aba5c88617891ab3b0ba34f3f3a503fa20009eae1a401c81"},
"ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"},
"gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"}, "gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"},
"grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"}, "grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"},
"hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"}, "hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
"opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.3", "d2698bee882c354274563ee85d097bb736a9adb8d8ed376a4deea0cd3a14bb31", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "c9105933df0d783d94cf08d79206eb8d6578abc0bcbd498d0b497ec62a4e30a8"}, "opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.4", "1d4ae91e097152798b85844e85976e5c81f93873788fad04871bfeb939162664", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "b7f6278754ad4f51d7599f1f1213755e599834f34cb4d5843f70f3df8477ca2d"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.3.2", "588ebf85fa7d18eba8db297b7d0a2a654f680f35c4466cd0045cd12a6fda27d7", [:mix, :rebar3], [], "hexpm", "1e0ba55db6718d5797e72c00e3821e60e02f7829e3fb64dc1a7c96f7c2776a58"}, "opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.4", "13fb20b8800149ce52daa8fb793c1a45b826cc4bd0d5bc7e8a00cab46285cbe6", [:mix, :rebar3], [], "hexpm", "29c5bf7d5c40c4b9816906277beb2438e6737073721c75398465b1acd1b56b06"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.3", "76f5657d4c94a12003d9ed2c8da1023c815e98f5553184dbb0cdaeec76db676d", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.3", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "267f0e4c3f1f5557cc7ad6ac71d66b8eaf7b3b56fde942c21f8a0bc96174fe1e"}, "opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.4", "c614400fdfb3616bd6607b8b26348f23f2d4b96621af2b4f585e75618528ffd3", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.4", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.11", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "df303b2b9829b1896f670ca2d1ccd1d32fb44e66558091d0584033276e674465"},
"postgrex": {:hex, :postgrex, "0.15.11", "50abbb50f33d22d79af402e549b9a566ba4f0451b4f5fd39b72d9bbd49743d24", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "6f0e5c3ea10f97468f5ff852277cb207f068399eb68b0c06c142ef68a4e82952"}, "postgrex": {:hex, :postgrex, "0.15.13", "7794e697481799aee8982688c261901de493eb64451feee6ea58207d7266d54a", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "3ffb76e1a97cfefe5c6a95632a27ffb67f28871c9741fb585f9d1c3cd2af70f1"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
"tls_certificate_check": {:hex, :tls_certificate_check, "1.11.0", "609dcd503f31170f0799dac380eb0e086388cf918fc769aaa60ddd6bbf575218", [:rebar3], [{:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "4ab962212ef7c87482619cb298e1fe06e047b57f0bd58cc417b3b299eb8d036e"},
} }

View File

@ -0,0 +1 @@
[].

View File

@ -41,11 +41,11 @@ defmodule OpentelemetryEctoTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "opentelemetry_ecto.test_repo.query:users", name: "opentelemetry_ecto.test_repo.query:users",
attributes: list, attributes: attributes,
kind: :client kind: :client
)} )}
assert [ assert %{
"db.instance": "opentelemetry_ecto_test", "db.instance": "opentelemetry_ecto_test",
"db.statement": "SELECT u0.\"id\", u0.\"email\" FROM \"users\" AS u0", "db.statement": "SELECT u0.\"id\", u0.\"email\" FROM \"users\" AS u0",
"db.type": :sql, "db.type": :sql,
@ -55,7 +55,7 @@ defmodule OpentelemetryEctoTest do
queue_time_microseconds: _, queue_time_microseconds: _,
source: "users", source: "users",
total_time_microseconds: _ total_time_microseconds: _
] = List.keysort(list, 0) } = :otel_attributes.map(attributes)
end end
test "changes the time unit" do test "changes the time unit" do
@ -66,10 +66,10 @@ defmodule OpentelemetryEctoTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "opentelemetry_ecto.test_repo.query:posts", name: "opentelemetry_ecto.test_repo.query:posts",
attributes: list attributes: attributes
)} )}
assert [ assert %{
"db.instance": "opentelemetry_ecto_test", "db.instance": "opentelemetry_ecto_test",
"db.statement": "SELECT p0.\"id\", p0.\"body\", p0.\"user_id\" FROM \"posts\" AS p0", "db.statement": "SELECT p0.\"id\", p0.\"body\", p0.\"user_id\" FROM \"posts\" AS p0",
"db.type": :sql, "db.type": :sql,
@ -79,7 +79,7 @@ defmodule OpentelemetryEctoTest do
queue_time_milliseconds: _, queue_time_milliseconds: _,
source: "posts", source: "posts",
total_time_milliseconds: _ total_time_milliseconds: _
] = List.keysort(list, 0) } = :otel_attributes.map(attributes)
end end
test "changes the span name prefix" do test "changes the span name prefix" do

View File

@ -1,2 +0,0 @@
erlang 23.2
elixir 1.11

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 0.2.0-rc.4
### Changed
* Opentelemetry 1.0.0-rc.4 support
## 0.1.0 ## 0.1.0
* Initial release * Initial release

View File

@ -11,7 +11,7 @@ dependencies in `mix.exs`:
```elixir ```elixir
def deps do def deps do
[ [
{:opentelemetry_oban, "~> 0.1"} {:opentelemetry_oban, "~> 0.2"}
] ]
end end
``` ```

View File

@ -0,0 +1,11 @@
version: "3.7"
services:
postgres:
image: postgres:13.3
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=opentelemetry_oban_test
ports:
- 5432:5432

View File

@ -21,8 +21,6 @@ defmodule OpentelemetryOban do
require OpenTelemetry.Tracer require OpenTelemetry.Tracer
@tracer_id :opentelemetry_oban
@doc """ @doc """
Initializes and configures telemetry handlers. Initializes and configures telemetry handlers.
@ -38,9 +36,6 @@ defmodule OpentelemetryOban do
""" """
@spec setup() :: :ok @spec setup() :: :ok
def setup(opts \\ []) do def setup(opts \\ []) do
{:ok, otel_tracer_vsn} = :application.get_key(@tracer_id, :vsn)
OpenTelemetry.register_tracer(@tracer_id, otel_tracer_vsn)
trace = Keyword.get(opts, :trace, [:jobs, :plugins]) trace = Keyword.get(opts, :trace, [:jobs, :plugins])
if Enum.member?(trace, :jobs) do if Enum.member?(trace, :jobs) do
@ -107,7 +102,7 @@ defmodule OpentelemetryOban do
# changesets in insert_all can include different workers and different # changesets in insert_all can include different workers and different
# queues. This means we cannot provide much information here, but we can # queues. This means we cannot provide much information here, but we can
# still record the insert and propagate the context information. # still record the insert and propagate the context information.
OpenTelemetry.Tracer.with_span "Oban bulk insert", kind: :producer do OpenTelemetry.Tracer.with_span :"Oban bulk insert", kind: :producer do
changesets = Enum.map(changesets, &add_tracing_information_to_meta/1) changesets = Enum.map(changesets, &add_tracing_information_to_meta/1)
Oban.insert_all(name, changesets) Oban.insert_all(name, changesets)
end end
@ -132,19 +127,19 @@ defmodule OpentelemetryOban do
queue = Changeset.get_field(changeset, :queue, "unknown") queue = Changeset.get_field(changeset, :queue, "unknown")
worker = Changeset.get_field(changeset, :worker, "unknown") worker = Changeset.get_field(changeset, :worker, "unknown")
[ %{
"messaging.system": "oban", "messaging.system": :oban,
"messaging.destination": queue, "messaging.destination": queue,
"messaging.destination_kind": "queue", "messaging.destination_kind": :queue,
"messaging.oban.worker": worker "messaging.oban.worker": worker
] }
end end
defp attributes_after_insert(job) do defp attributes_after_insert(job) do
[ %{
"messaging.oban.job_id": job.id, "messaging.oban.job_id": job.id,
"messaging.oban.priority": job.priority, "messaging.oban.priority": job.priority,
"messaging.oban.max_attempts": job.max_attempts "messaging.oban.max_attempts": job.max_attempts
] }
end end
end end

View File

@ -1,7 +1,7 @@
defmodule OpentelemetryOban.JobHandler do defmodule OpentelemetryOban.JobHandler do
alias OpenTelemetry.Span alias OpenTelemetry.Span
@tracer_id :opentelemetry_oban @tracer_id __MODULE__
def attach() do def attach() do
attach_job_start_handler() attach_job_start_handler()
@ -56,11 +56,11 @@ defmodule OpentelemetryOban.JobHandler do
links = if parent == :undefined, do: [], else: [OpenTelemetry.link(parent)] links = if parent == :undefined, do: [], else: [OpenTelemetry.link(parent)]
OpenTelemetry.Tracer.set_current_span(:undefined) OpenTelemetry.Tracer.set_current_span(:undefined)
attributes = [ attributes = %{
"messaging.system": "oban", "messaging.system": :oban,
"messaging.destination": queue, "messaging.destination": queue,
"messaging.destination_kind": "queue", "messaging.destination_kind": :queue,
"messaging.operation": "process", "messaging.operation": :process,
"messaging.oban.job_id": id, "messaging.oban.job_id": id,
"messaging.oban.worker": worker, "messaging.oban.worker": worker,
"messaging.oban.priority": priority, "messaging.oban.priority": priority,
@ -69,7 +69,7 @@ defmodule OpentelemetryOban.JobHandler do
"messaging.oban.inserted_at": "messaging.oban.inserted_at":
if(inserted_at, do: DateTime.to_iso8601(inserted_at), else: nil), if(inserted_at, do: DateTime.to_iso8601(inserted_at), else: nil),
"messaging.oban.scheduled_at": DateTime.to_iso8601(scheduled_at) "messaging.oban.scheduled_at": DateTime.to_iso8601(scheduled_at)
] }
span_name = "#{worker} process" span_name = "#{worker} process"

View File

@ -1,7 +1,7 @@
defmodule OpentelemetryOban.PluginHandler do defmodule OpentelemetryOban.PluginHandler do
alias OpenTelemetry.Span alias OpenTelemetry.Span
@tracer_id :opentelemetry_oban @tracer_id __MODULE__
def attach() do def attach() do
attach_plugin_start_handler() attach_plugin_start_handler()

View File

@ -4,7 +4,7 @@ defmodule OpentelemetryOban.MixProject do
def project do def project do
[ [
app: :opentelemetry_oban, app: :opentelemetry_oban,
version: "0.2.0-rc.3", version: "0.2.0-rc.4",
elixir: "~> 1.10", elixir: "~> 1.10",
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
deps: deps(), deps: deps(),
@ -39,12 +39,12 @@ defmodule OpentelemetryOban.MixProject do
defp deps do defp deps do
[ [
{:oban, "~> 2.0"}, {:oban, "~> 2.0"},
{:opentelemetry_api, "~> 1.0.0-rc.3"}, {:opentelemetry_api, "~> 1.0.0-rc.4"},
{:opentelemetry_telemetry, "~> 1.0.0-beta"}, {:opentelemetry_telemetry, "~> 1.0.0-beta.6"},
{:opentelemetry, "~> 1.0.0-rc.3", only: [:test]}, {:opentelemetry, "~> 1.0.0-rc.4", only: [:test]},
{:opentelemetry_exporter, "~> 1.0.0-rc.3", only: [:test]}, {:opentelemetry_exporter, "~> 1.0.0-rc.4", only: [:test]},
{:telemetry, "~> 0.4 or ~> 1.0"}, {:telemetry, "~> 0.4 or ~> 1.0"},
{:ex_doc, "~> 0.24", only: [:dev], runtime: false} {:ex_doc, "~> 0.26", only: [:dev], runtime: false}
] ]
end end

View File

@ -3,26 +3,28 @@
"chatterbox": {:hex, :ts_chatterbox, "0.11.0", "b8f372c706023eb0de5bf2976764edb27c70fe67052c88c1f6a66b3a5626847f", [:rebar3], [{:hpack, "~>0.2.3", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "722fe2bad52913ab7e87d849fc6370375f0c961ffb2f0b5e6d647c9170c382a6"}, "chatterbox": {:hex, :ts_chatterbox, "0.11.0", "b8f372c706023eb0de5bf2976764edb27c70fe67052c88c1f6a66b3a5626847f", [:rebar3], [{:hpack, "~>0.2.3", [hex: :hpack_erl, repo: "hexpm", optional: false]}], "hexpm", "722fe2bad52913ab7e87d849fc6370375f0c961ffb2f0b5e6d647c9170c382a6"},
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
"ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"}, "ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"},
"db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"}, "db_connection": {:hex, :db_connection, "2.4.1", "6411f6e23f1a8b68a82fa3a36366d4881f21f47fc79a9efb8c615e62050219da", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ea36d226ec5999781a9a8ad64e5d8c4454ecedc7a4d643e4832bf08efca01f00"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"}, "earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"},
"ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"}, "ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"},
"ecto_sql": {:hex, :ecto_sql, "3.7.0", "2fcaad4ab0c8d76a5afbef078162806adbe709c04160aca58400d5cbbe8eeac6", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a26135dfa1d99bf87a928c464cfa25bba6535a4fe761eefa56077a4febc60f70"}, "ecto_sql": {:hex, :ecto_sql, "3.7.1", "8de624ef50b2a8540252d8c60506379fbbc2707be1606853df371cf53df5d053", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2b42a32e2ce92f64aba5c88617891ab3b0ba34f3f3a503fa20009eae1a401c81"},
"ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"}, "ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"},
"gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"}, "gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"},
"grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"}, "grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"},
"hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"}, "hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
"oban": {:hex, :oban, "2.8.0", "e44b19a30e30bb983099f55d59749316ff0eaf5dfef4214e1190738176653e50", [:mix], [{:ecto_sql, ">= 3.4.3", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2954a2ac418f7cc4217c0772a3dd3a70e2966240583b97f4126a489e1300a573"}, "oban": {:hex, :oban, "2.10.1", "202a90f2aed0130b7d750bdbfea8090c8321bce255bade10fd3699733565add0", [:mix], [{:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "161cdd01194147cd6a3efdb1d6c3d9689309991412f799c1e242c18912e307c3"},
"opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.3", "d2698bee882c354274563ee85d097bb736a9adb8d8ed376a4deea0cd3a14bb31", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "c9105933df0d783d94cf08d79206eb8d6578abc0bcbd498d0b497ec62a4e30a8"}, "opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.4", "1d4ae91e097152798b85844e85976e5c81f93873788fad04871bfeb939162664", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "b7f6278754ad4f51d7599f1f1213755e599834f34cb4d5843f70f3df8477ca2d"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.3.1", "d183663c178f317a109a267b3c3664d09db22829a4d4eea8d9af46ed3e5bee05", [:mix, :rebar3], [], "hexpm", "4b836cec1b531080c310fa54afca6e523984a1f6c1aeb5d4da537dad9e309ce9"}, "opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.4", "13fb20b8800149ce52daa8fb793c1a45b826cc4bd0d5bc7e8a00cab46285cbe6", [:mix, :rebar3], [], "hexpm", "29c5bf7d5c40c4b9816906277beb2438e6737073721c75398465b1acd1b56b06"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.3", "76f5657d4c94a12003d9ed2c8da1023c815e98f5553184dbb0cdaeec76db676d", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.3", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "267f0e4c3f1f5557cc7ad6ac71d66b8eaf7b3b56fde942c21f8a0bc96174fe1e"}, "opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.4", "c614400fdfb3616bd6607b8b26348f23f2d4b96621af2b4f585e75618528ffd3", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.4", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.11", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "df303b2b9829b1896f670ca2d1ccd1d32fb44e66558091d0584033276e674465"},
"opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0-beta.2", "b840eee9e68307ad7fa4ee316da19db3f8e30763b87737d3304782ca3cc296a2", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.1", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.2.1", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "e8b12f42614d0aeb6a49001c75ca035544950f736fdbb240177838674f99e1e2"}, "opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0-beta.6.1", "cb8b9e0cc1e740d7fedcb2f60498877a7593b1e46932076aac9b58708c64763e", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "6be70f51cd519ec225eed6018b747aaa7fb3176460669d7e9776745ff48753ac"},
"postgrex": {:hex, :postgrex, "0.15.10", "2809dee1b1d76f7cbabe570b2a9285c2e7b41be60cf792f5f2804a54b838a067", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "1560ca427542f6b213f8e281633ae1a3b31cdbcd84ebd7f50628765b8f6132be"}, "postgrex": {:hex, :postgrex, "0.15.13", "7794e697481799aee8982688c261901de493eb64451feee6ea58207d7266d54a", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "3ffb76e1a97cfefe5c6a95632a27ffb67f28871c9741fb585f9d1c3cd2af70f1"},
"telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"telemetry_registry": {:hex, :telemetry_registry, "0.2.1", "fe648a691f2128e4279d993cd010994c67f282354dc061e697bf070d4b87b480", [:mix, :rebar3], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4221cefbcadd0b3e7076960339223742d973f1371bc20f3826af640257bc3690"}, "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
"telemetry_registry": {:hex, :telemetry_registry, "0.3.0", "6768f151ea53fc0fbca70dbff5b20a8d663ee4e0c0b2ae589590e08658e76f1e", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "492e2adbc609f3e79ece7f29fec363a97a2c484ac78a83098535d6564781e917"},
"tls_certificate_check": {:hex, :tls_certificate_check, "1.11.0", "609dcd503f31170f0799dac380eb0e086388cf918fc769aaa60ddd6bbf575218", [:rebar3], [{:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "4ab962212ef7c87482619cb298e1fe06e047b57f0bd58cc417b3b299eb8d036e"},
} }

View File

@ -95,18 +95,18 @@ defmodule OpentelemetryOban.PluginHandlerTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "Elixir.Oban.Plugins.Stager process", name: "Elixir.Oban.Plugins.Stager process",
events: [ events: events,
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.UndefinedFunctionError"},
{"exception.message",
"function Some.error/0 is undefined (module Some is not available)"},
{"exception.stacktrace", _stacktrace}
]
)
],
status: ^expected_status status: ^expected_status
)} )}
[
event(
name: "exception",
attributes: event_attributes
)
] = :otel_events.list(events)
assert ["exception.message", "exception.stacktrace", "exception.type"] ==
Map.keys(:otel_attributes.map(event_attributes))
end end
end end

View File

@ -44,15 +44,15 @@ defmodule OpentelemetryObanTest do
status: :undefined status: :undefined
)} )}
assert [ assert %{
"messaging.destination": "events", "messaging.destination": "events",
"messaging.destination_kind": "queue", "messaging.destination_kind": :queue,
"messaging.oban.job_id": _job_id, "messaging.oban.job_id": _job_id,
"messaging.oban.max_attempts": 1, "messaging.oban.max_attempts": 1,
"messaging.oban.priority": 0, "messaging.oban.priority": 0,
"messaging.oban.worker": "TestJob", "messaging.oban.worker": "TestJob",
"messaging.system": "oban" "messaging.system": :oban
] = List.keysort(attributes, 0) } = :otel_attributes.map(attributes)
end end
test "job creation uses existing trace if present" do test "job creation uses existing trace if present" do
@ -104,9 +104,11 @@ defmodule OpentelemetryObanTest do
kind: :consumer, kind: :consumer,
status: :undefined, status: :undefined,
trace_id: process_trace_id, trace_id: process_trace_id,
links: [link(trace_id: ^send_trace_id, span_id: ^send_span_id)] links: links
)} )}
[link(trace_id: ^send_trace_id, span_id: ^send_span_id)] = :otel_links.list(links)
# Process is ran asynchronously so we create a new trace, but still link # Process is ran asynchronously so we create a new trace, but still link
# the traces together. # the traces together.
assert send_trace_id != process_trace_id assert send_trace_id != process_trace_id
@ -124,8 +126,10 @@ defmodule OpentelemetryObanTest do
kind: :consumer, kind: :consumer,
status: :undefined, status: :undefined,
trace_id: _trace_id, trace_id: _trace_id,
links: [] links: links
)} )}
assert [] == :otel_links.list(links)
end end
test "records spans for successful Oban jobs" do test "records spans for successful Oban jobs" do
@ -140,9 +144,9 @@ defmodule OpentelemetryObanTest do
status: :undefined status: :undefined
)} )}
assert [ assert %{
"messaging.destination": "events", "messaging.destination": "events",
"messaging.destination_kind": "queue", "messaging.destination_kind": :queue,
"messaging.oban.attempt": 1, "messaging.oban.attempt": 1,
"messaging.oban.inserted_at": _inserted_at, "messaging.oban.inserted_at": _inserted_at,
"messaging.oban.job_id": _job_id, "messaging.oban.job_id": _job_id,
@ -150,9 +154,9 @@ defmodule OpentelemetryObanTest do
"messaging.oban.priority": 0, "messaging.oban.priority": 0,
"messaging.oban.scheduled_at": _scheduled_at, "messaging.oban.scheduled_at": _scheduled_at,
"messaging.oban.worker": "TestJob", "messaging.oban.worker": "TestJob",
"messaging.operation": "process", "messaging.operation": :process,
"messaging.system": "oban" "messaging.system": :oban
] = List.keysort(attributes, 0) } = :otel_attributes.map(attributes)
end end
test "records spans for Oban jobs that stop with {:error, :something}" do test "records spans for Oban jobs that stop with {:error, :something}" do
@ -166,23 +170,13 @@ defmodule OpentelemetryObanTest do
name: "TestJobThatReturnsError process", name: "TestJobThatReturnsError process",
attributes: attributes, attributes: attributes,
kind: :consumer, kind: :consumer,
events: [ events: events,
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.Oban.PerformError"},
{"exception.message",
"TestJobThatReturnsError failed with {:error, :something}"},
{"exception.stacktrace", _stacktrace}
]
)
],
status: ^expected_status status: ^expected_status
)} )}
assert [ assert %{
"messaging.destination": "events", "messaging.destination": "events",
"messaging.destination_kind": "queue", "messaging.destination_kind": :queue,
"messaging.oban.attempt": 1, "messaging.oban.attempt": 1,
"messaging.oban.inserted_at": _inserted_at, "messaging.oban.inserted_at": _inserted_at,
"messaging.oban.job_id": _job_id, "messaging.oban.job_id": _job_id,
@ -190,9 +184,19 @@ defmodule OpentelemetryObanTest do
"messaging.oban.priority": 0, "messaging.oban.priority": 0,
"messaging.oban.scheduled_at": _scheduled_at, "messaging.oban.scheduled_at": _scheduled_at,
"messaging.oban.worker": "TestJobThatReturnsError", "messaging.oban.worker": "TestJobThatReturnsError",
"messaging.operation": "process", "messaging.operation": :process,
"messaging.system": "oban" "messaging.system": :oban
] = List.keysort(attributes, 0) } = :otel_attributes.map(attributes)
[
event(
name: "exception",
attributes: event_attributes
)
] = :otel_events.list(events)
assert ["exception.message", "exception.stacktrace", "exception.type"] ==
Map.keys(:otel_attributes.map(event_attributes))
end end
test "records spans for each retry" do test "records spans for each retry" do
@ -215,17 +219,21 @@ defmodule OpentelemetryObanTest do
name: "TestJobThatReturnsError process", name: "TestJobThatReturnsError process",
status: ^expected_status, status: ^expected_status,
trace_id: first_process_trace_id, trace_id: first_process_trace_id,
links: [link(trace_id: ^send_trace_id, span_id: ^send_span_id)] links: job_1_links
)} )}
[link(trace_id: ^send_trace_id, span_id: ^send_span_id)] = :otel_links.list(job_1_links)
assert_receive {:span, assert_receive {:span,
span( span(
name: "TestJobThatReturnsError process", name: "TestJobThatReturnsError process",
status: ^expected_status, status: ^expected_status,
trace_id: second_process_trace_id, trace_id: second_process_trace_id,
links: [link(trace_id: ^send_trace_id, span_id: ^send_span_id)] links: job_2_links
)} )}
[link(trace_id: ^send_trace_id, span_id: ^send_span_id)] = :otel_links.list(job_2_links)
assert first_process_trace_id != second_process_trace_id assert first_process_trace_id != second_process_trace_id
end end
@ -240,23 +248,13 @@ defmodule OpentelemetryObanTest do
name: "TestJobThatThrowsException process", name: "TestJobThatThrowsException process",
attributes: attributes, attributes: attributes,
kind: :consumer, kind: :consumer,
events: [ events: events,
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.UndefinedFunctionError"},
{"exception.message",
"function Some.error/0 is undefined (module Some is not available)"},
{"exception.stacktrace", _stacktrace}
]
)
],
status: ^expected_status status: ^expected_status
)} )}
assert [ assert %{
"messaging.destination": "events", "messaging.destination": "events",
"messaging.destination_kind": "queue", "messaging.destination_kind": :queue,
"messaging.oban.attempt": 1, "messaging.oban.attempt": 1,
"messaging.oban.inserted_at": _inserted_at, "messaging.oban.inserted_at": _inserted_at,
"messaging.oban.job_id": _job_id, "messaging.oban.job_id": _job_id,
@ -264,9 +262,19 @@ defmodule OpentelemetryObanTest do
"messaging.oban.priority": 0, "messaging.oban.priority": 0,
"messaging.oban.scheduled_at": _scheduled_at, "messaging.oban.scheduled_at": _scheduled_at,
"messaging.oban.worker": "TestJobThatThrowsException", "messaging.oban.worker": "TestJobThatThrowsException",
"messaging.operation": "process", "messaging.operation": :process,
"messaging.system": "oban" "messaging.system": :oban
] = List.keysort(attributes, 0) } = :otel_attributes.map(attributes)
[
event(
name: "exception",
attributes: event_attributes
)
] = :otel_events.list(events)
assert ["exception.message", "exception.stacktrace", "exception.type"] ==
Map.keys(:otel_attributes.map(event_attributes))
end end
test "spans inside the job are associated with the job trace" do test "spans inside the job are associated with the job trace" do
@ -310,19 +318,20 @@ defmodule OpentelemetryObanTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "TestJob send", name: "TestJob send",
events: [ events: events,
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.Ecto.InvalidChangesetError"},
{"exception.message", _message},
{"exception.stacktrace", _stacktrace}
]
)
],
status: ^expected_status status: ^expected_status
)} )}
[
event(
name: "exception",
attributes: event_attributes
)
] = :otel_events.list(events)
assert ["exception.message", "exception.stacktrace", "exception.type"] ==
Map.keys(:otel_attributes.map(event_attributes))
refute_received {:span, span(name: "TestJob process")} refute_received {:span, span(name: "TestJob process")}
end end
@ -336,7 +345,7 @@ defmodule OpentelemetryObanTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "Oban bulk insert", name: :"Oban bulk insert",
attributes: _attributes, attributes: _attributes,
trace_id: send_trace_id, trace_id: send_trace_id,
span_id: send_span_id, span_id: send_span_id,
@ -351,9 +360,11 @@ defmodule OpentelemetryObanTest do
kind: :consumer, kind: :consumer,
status: :undefined, status: :undefined,
trace_id: first_process_trace_id, trace_id: first_process_trace_id,
links: [link(trace_id: ^send_trace_id, span_id: ^send_span_id)] links: job_1_links
)} )}
[link(trace_id: ^send_trace_id, span_id: ^send_span_id)] = :otel_links.list(job_1_links)
assert_receive {:span, assert_receive {:span,
span( span(
name: "TestJob process", name: "TestJob process",
@ -361,9 +372,11 @@ defmodule OpentelemetryObanTest do
kind: :consumer, kind: :consumer,
status: :undefined, status: :undefined,
trace_id: second_process_trace_id, trace_id: second_process_trace_id,
links: [link(trace_id: ^send_trace_id, span_id: ^send_span_id)] links: job_2_links
)} )}
[link(trace_id: ^send_trace_id, span_id: ^send_span_id)] = :otel_links.list(job_2_links)
# Process is ran asynchronously so we create a new trace, but still link # Process is ran asynchronously so we create a new trace, but still link
# the traces together. # the traces together.
assert send_trace_id != first_process_trace_id assert send_trace_id != first_process_trace_id

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
## 1.0.0-rc.6
### Changed
* Opentelemetry 1.0.0-rc.4 support
### Fixes
* pass attributes on span start for better sampling options
* fix http status attribute to match spec
## 1.0.0-rc.4 ## 1.0.0-rc.4
### Changed ### Changed

View File

@ -22,7 +22,7 @@ may be supplied.
```elixir ```elixir
def deps do def deps do
[ [
{:opentelemetry_phoenix, "~> 1.0.0-rc.5"} {:opentelemetry_phoenix, "~> 1.0.0-rc.6"}
] ]
end end
``` ```
@ -37,6 +37,7 @@ end
| | v1.0.0-rc.2 | | | | v1.0.0-rc.2 | |
| v1.0.0-rc.4 | v1.0.0-rc.2 | Otel rc.3 will be a breaking change | | v1.0.0-rc.4 | v1.0.0-rc.2 | Otel rc.3 will be a breaking change |
| v1.0.0-rc.5 | v1.0.0-rc.3 | | | v1.0.0-rc.5 | v1.0.0-rc.3 | |
| v1.0.0-rc.6 | v1.0.0-rc.4 | |
## Note on phoenix integration ## Note on phoenix integration

View File

@ -1,6 +1,6 @@
# This file is responsible for configuring your application # This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module. # and its dependencies with the aid of the Mix.Config module.
use Mix.Config import Config
# This configuration is loaded before any dependency and is restricted # This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this # to this project. If another project depends on this project, this

View File

@ -1,2 +1,4 @@
import Config
config :opentelemetry, config :opentelemetry,
processors: [{:otel_batch_processor, %{scheduled_delay_ms: 1}}] processors: [{:otel_batch_processor, %{scheduled_delay_ms: 1}}]

View File

@ -27,7 +27,7 @@ defmodule OpentelemetryPhoenix do
alias OpenTelemetry.Span alias OpenTelemetry.Span
alias OpentelemetryPhoenix.Reason alias OpentelemetryPhoenix.Reason
@tracer_id :opentelemetry_phoenix @tracer_id __MODULE__
@typedoc "Setup options" @typedoc "Setup options"
@type opts :: [endpoint_prefix()] @type opts :: [endpoint_prefix()]
@ -106,7 +106,7 @@ defmodule OpentelemetryPhoenix do
user_agent = header_value(conn, "user-agent") user_agent = header_value(conn, "user-agent")
peer_ip = Map.get(peer_data, :address) peer_ip = Map.get(peer_data, :address)
attributes = [ attributes = %{
"http.client_ip": client_ip(conn), "http.client_ip": client_ip(conn),
"http.flavor": http_flavor(adapter), "http.flavor": http_flavor(adapter),
"http.host": conn.host, "http.host": conn.host,
@ -119,7 +119,7 @@ defmodule OpentelemetryPhoenix do
"net.peer.ip": to_string(:inet_parse.ntoa(peer_ip)), "net.peer.ip": to_string(:inet_parse.ntoa(peer_ip)),
"net.peer.port": peer_data.port, "net.peer.port": peer_data.port,
"net.transport": :"IP.TCP" "net.transport": :"IP.TCP"
] }
# start the span with a default name. Route name isn't known until router dispatch # start the span with a default name. Route name isn't known until router dispatch
OpentelemetryTelemetry.start_telemetry_span(@tracer_id, "HTTP #{conn.method}", meta, %{ OpentelemetryTelemetry.start_telemetry_span(@tracer_id, "HTTP #{conn.method}", meta, %{
@ -145,11 +145,11 @@ defmodule OpentelemetryPhoenix do
@doc false @doc false
def handle_router_dispatch_start(_event, _measurements, meta, _config) do def handle_router_dispatch_start(_event, _measurements, meta, _config) do
attributes = [ attributes = %{
"phoenix.plug": meta.plug, "phoenix.plug": meta.plug,
"phoenix.action": meta.plug_opts, "phoenix.action": meta.plug_opts,
"http.route": meta.route "http.route": meta.route
] }
# Add more info that we now know about but don't close the span # Add more info that we now know about but don't close the span
ctx = OpentelemetryTelemetry.set_current_telemetry_span(@tracer_id, meta) ctx = OpentelemetryTelemetry.set_current_telemetry_span(@tracer_id, meta)

View File

@ -5,7 +5,7 @@ defmodule OpentelemetryPhoenix.MixProject do
[ [
app: :opentelemetry_phoenix, app: :opentelemetry_phoenix,
description: description(), description: description(),
version: "1.0.0-rc.5", version: "1.0.0-rc.6",
elixir: "~> 1.10", elixir: "~> 1.10",
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
dialyzer: [ dialyzer: [
@ -58,14 +58,14 @@ defmodule OpentelemetryPhoenix.MixProject do
# Run "mix help deps" to learn about dependencies. # Run "mix help deps" to learn about dependencies.
defp deps do defp deps do
[ [
{:opentelemetry_api, "~> 1.0.0-rc.3"}, {:opentelemetry_api, "~> 1.0.0-rc.4"},
{:opentelemetry_telemetry, "~> 1.0.0-beta.4"}, {:opentelemetry_telemetry, "~> 1.0.0-beta.6"},
{:telemetry, "~> 0.4 or ~> 1.0.0"}, {:telemetry, "~> 0.4 or ~> 1.0.0"},
{:cowboy_telemetry, "~> 0.4", only: [:dev, :test]}, {:cowboy_telemetry, "~> 0.4", only: [:dev, :test]},
{:opentelemetry, "~> 1.0.0-rc.3", only: [:dev, :test]}, {:opentelemetry, "~> 1.0.0-rc.4", only: [:dev, :test]},
{:opentelemetry_exporter, "~> 1.0.0-rc.3", only: [:dev, :test]}, {:opentelemetry_exporter, "~> 1.0.0-rc.4", only: [:dev, :test]},
{:plug, "~> 1.11", only: [:dev, :test]}, {:plug, "~> 1.11", only: [:dev, :test]},
{:ex_doc, "~> 0.24", only: [:dev], runtime: false}, {:ex_doc, "~> 0.26", only: [:dev], runtime: false},
{:plug_cowboy, "~> 2.4", only: [:dev, :test]}, {:plug_cowboy, "~> 2.4", only: [:dev, :test]},
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false} {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false}
] ]

View File

@ -7,25 +7,27 @@
"ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"}, "ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark": {:hex, :earmark, "1.4.10", "bddce5e8ea37712a5bfb01541be8ba57d3b171d3fa4f80a0be9bcf1db417bcaf", [:mix], [{:earmark_parser, ">= 1.4.10", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "12dbfa80810478e521d3ffb941ad9fbfcbbd7debe94e1341b4c4a1b2411c1c27"}, "earmark": {:hex, :earmark, "1.4.10", "bddce5e8ea37712a5bfb01541be8ba57d3b171d3fa4f80a0be9bcf1db417bcaf", [:mix], [{:earmark_parser, ">= 1.4.10", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "12dbfa80810478e521d3ffb941ad9fbfcbbd7debe94e1341b4c4a1b2411c1c27"},
"earmark_parser": {:hex, :earmark_parser, "1.4.16", "607709303e1d4e3e02f1444df0c821529af1c03b8578dfc81bb9cf64553d02b9", [:mix], [], "hexpm", "69fcf696168f5a274dd012e3e305027010658b2d1630cef68421d6baaeaccead"}, "earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"}, "ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"},
"gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"}, "gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"},
"grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"}, "grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"},
"hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"}, "hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"}, "mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
"opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.3", "d2698bee882c354274563ee85d097bb736a9adb8d8ed376a4deea0cd3a14bb31", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "c9105933df0d783d94cf08d79206eb8d6578abc0bcbd498d0b497ec62a4e30a8"}, "opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.4", "1d4ae91e097152798b85844e85976e5c81f93873788fad04871bfeb939162664", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "b7f6278754ad4f51d7599f1f1213755e599834f34cb4d5843f70f3df8477ca2d"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.3.2", "588ebf85fa7d18eba8db297b7d0a2a654f680f35c4466cd0045cd12a6fda27d7", [:mix, :rebar3], [], "hexpm", "1e0ba55db6718d5797e72c00e3821e60e02f7829e3fb64dc1a7c96f7c2776a58"}, "opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.4", "13fb20b8800149ce52daa8fb793c1a45b826cc4bd0d5bc7e8a00cab46285cbe6", [:mix, :rebar3], [], "hexpm", "29c5bf7d5c40c4b9816906277beb2438e6737073721c75398465b1acd1b56b06"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.3", "76f5657d4c94a12003d9ed2c8da1023c815e98f5553184dbb0cdaeec76db676d", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.3", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "267f0e4c3f1f5557cc7ad6ac71d66b8eaf7b3b56fde942c21f8a0bc96174fe1e"}, "opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.4", "c614400fdfb3616bd6607b8b26348f23f2d4b96621af2b4f585e75618528ffd3", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.4", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.11", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "df303b2b9829b1896f670ca2d1ccd1d32fb44e66558091d0584033276e674465"},
"opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0-beta.4", "74b2a9de1b2f1c22955a2fa3263d65a979fd64bf69d3d1571b5c34fdfed95cfa", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "6ebba3c47a26460a7302bfcdccf87582eeb1a71c2e6abc47845787dcd04fb256"}, "opentelemetry_telemetry": {:hex, :opentelemetry_telemetry, "1.0.0-beta.6.1", "cb8b9e0cc1e740d7fedcb2f60498877a7593b1e46932076aac9b58708c64763e", [:mix, :rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.3.0", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "6be70f51cd519ec225eed6018b747aaa7fb3176460669d7e9776745ff48753ac"},
"plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"}, "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"},
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"}, "plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
"plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
"telemetry_registry": {:hex, :telemetry_registry, "0.3.0", "6768f151ea53fc0fbca70dbff5b20a8d663ee4e0c0b2ae589590e08658e76f1e", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "492e2adbc609f3e79ece7f29fec363a97a2c484ac78a83098535d6564781e917"}, "telemetry_registry": {:hex, :telemetry_registry, "0.3.0", "6768f151ea53fc0fbca70dbff5b20a8d663ee4e0c0b2ae589590e08658e76f1e", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "492e2adbc609f3e79ece7f29fec363a97a2c484ac78a83098535d6564781e917"},
"tls_certificate_check": {:hex, :tls_certificate_check, "1.11.0", "609dcd503f31170f0799dac380eb0e086388cf918fc769aaa60ddd6bbf575218", [:rebar3], [{:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "4ab962212ef7c87482619cb298e1fe06e047b57f0bd58cc417b3b299eb8d036e"},
} }

View File

@ -54,11 +54,11 @@ defmodule OpentelemetryPhoenixTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "/users/:user_id", name: "/users/:user_id",
attributes: list, attributes: attributes,
parent_span_id: 13_235_353_014_750_950_193 parent_span_id: 13_235_353_014_750_950_193
)} )}
assert [ assert %{
"http.client_ip": "10.211.55.2", "http.client_ip": "10.211.55.2",
"http.flavor": :"1.1", "http.flavor": :"1.1",
"http.host": "localhost", "http.host": "localhost",
@ -75,7 +75,7 @@ defmodule OpentelemetryPhoenixTest do
"net.transport": :"IP.TCP", "net.transport": :"IP.TCP",
"phoenix.action": :user, "phoenix.action": :user,
"phoenix.plug": Elixir.MyStoreWeb.PageController "phoenix.plug": Elixir.MyStoreWeb.PageController
] == List.keysort(list, 0) } == :otel_attributes.map(attributes)
end end
test "parses x-forwarded-for with single value" do test "parses x-forwarded-for with single value" do
@ -83,9 +83,9 @@ defmodule OpentelemetryPhoenixTest do
x_forwarded_for_request("203.0.113.195") x_forwarded_for_request("203.0.113.195")
assert_receive {:span, span(attributes: list)} assert_receive {:span, span(attributes: attributes)}
assert Keyword.fetch!(list, :"http.client_ip") == "203.0.113.195" assert Map.fetch!(:otel_attributes.map(attributes), :"http.client_ip") == "203.0.113.195"
end end
test "parses x-forwarded-for with multiple values" do test "parses x-forwarded-for with multiple values" do
@ -93,9 +93,9 @@ defmodule OpentelemetryPhoenixTest do
x_forwarded_for_request("203.0.113.195, 70.41.3.18, 150.172.238.178") x_forwarded_for_request("203.0.113.195, 70.41.3.18, 150.172.238.178")
assert_receive {:span, span(attributes: list)} assert_receive {:span, span(attributes: attributes)}
assert Keyword.fetch!(list, :"http.client_ip") == "203.0.113.195" assert Map.fetch!(:otel_attributes.map(attributes), :"http.client_ip") == "203.0.113.195"
end end
test "records exceptions for Phoenix web requests" do test "records exceptions for Phoenix web requests" do
@ -130,25 +130,14 @@ defmodule OpentelemetryPhoenixTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "/users/:user_id/exception", name: "/users/:user_id/exception",
attributes: list, attributes: attributes,
kind: :server, kind: :server,
events: [ events: events,
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.ErlangError"},
{"exception.message", "Erlang error: :badkey"},
{"exception.stacktrace", _stacktrace},
{:key, :name},
{:map, "%{username: \"rick\"}"}
]
)
],
parent_span_id: 13_235_353_014_750_950_193, parent_span_id: 13_235_353_014_750_950_193,
status: ^expected_status status: ^expected_status
)} )}
assert [ assert %{
"http.client_ip": "10.211.55.2", "http.client_ip": "10.211.55.2",
"http.flavor": :"1.1", "http.flavor": :"1.1",
"http.host": "localhost", "http.host": "localhost",
@ -165,7 +154,17 @@ defmodule OpentelemetryPhoenixTest do
"net.transport": :"IP.TCP", "net.transport": :"IP.TCP",
"phoenix.action": :code_exception, "phoenix.action": :code_exception,
"phoenix.plug": MyStoreWeb.PageController "phoenix.plug": MyStoreWeb.PageController
] == List.keysort(list, 0) } == :otel_attributes.map(attributes)
[
event(
name: "exception",
attributes: event_attributes
)
] = :otel_events.list(events)
assert [:key, :map, "exception.message", "exception.stacktrace", "exception.type"] ==
Map.keys(:otel_attributes.map(event_attributes))
end end
test "records exceptions for Phoenix web requests with plug wrappers" do test "records exceptions for Phoenix web requests with plug wrappers" do
@ -200,23 +199,14 @@ defmodule OpentelemetryPhoenixTest do
assert_receive {:span, assert_receive {:span,
span( span(
name: "/users/:user_id/exception", name: "/users/:user_id/exception",
attributes: list, attributes: attributes,
kind: :server, kind: :server,
events: [ events: events,
event(
name: "exception",
attributes: [
{"exception.type", "Elixir.ArithmeticError"},
{"exception.message", "bad argument in arithmetic expression"},
{"exception.stacktrace", _stacktrace}
]
)
],
parent_span_id: 13_235_353_014_750_950_193, parent_span_id: 13_235_353_014_750_950_193,
status: ^expected_status status: ^expected_status
)} )}
assert [ assert %{
"http.client_ip": "10.211.55.2", "http.client_ip": "10.211.55.2",
"http.flavor": :"1.1", "http.flavor": :"1.1",
"http.host": "localhost", "http.host": "localhost",
@ -233,7 +223,17 @@ defmodule OpentelemetryPhoenixTest do
"net.transport": :"IP.TCP", "net.transport": :"IP.TCP",
"phoenix.action": :code_exception, "phoenix.action": :code_exception,
"phoenix.plug": MyStoreWeb.PageController "phoenix.plug": MyStoreWeb.PageController
] == List.keysort(list, 0) } == :otel_attributes.map(attributes)
[
event(
name: "exception",
attributes: event_attributes
)
] = :otel_events.list(events)
assert ["exception.message", "exception.stacktrace", "exception.type"] ==
Map.keys(:otel_attributes.map(event_attributes))
end end
defp x_forwarded_for_request(x_forwarded_for) do defp x_forwarded_for_request(x_forwarded_for) do

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 1.0.0-beta.6
### Changes
* OpenTelemetry 1.0.0-rc.4 support
## 1.0.0-beta.4 ## 1.0.0-beta.4
### Changes ### Changes

View File

@ -27,14 +27,14 @@ by adding `opentelemetry_telemetry` to your list of dependencies:
```erlang ```erlang
{deps, [ {deps, [
{opentelemetry_telemetry, "~> 1.0.0-beta.5"} {opentelemetry_telemetry, "~> 1.0.0-beta.6"}
]}. ]}.
``` ```
```elixir ```elixir
def deps do def deps do
[ [
{:opentelemetry_telemetry, "~> 1.0.0-beta.5"} {:opentelemetry_telemetry, "~> 1.0.0-beta.6"}
] ]
end end
``` ```

View File

@ -1 +1 @@
1.0.0-beta.5 1.0.0-beta.6.1

View File

@ -94,7 +94,7 @@ defmodule OpentelemetryTelemetry do
tracer_id(), tracer_id(),
:opentelemetry.span_name(), :opentelemetry.span_name(),
:telemetry.event_metadata(), :telemetry.event_metadata(),
OpenTelemetry.Tracer.start_opts() OpenTelemetry.Span.start_opts()
) :: OpenTelemetry.span_ctx() ) :: OpenTelemetry.span_ctx()
defdelegate start_telemetry_span(tracer_id, span_name, event_metadata, start_opts), defdelegate start_telemetry_span(tracer_id, span_name, event_metadata, start_opts),
to: :otel_telemetry to: :otel_telemetry

View File

@ -55,9 +55,9 @@ defmodule OpentelemetryTelemetry.MixProject do
end) end)
|> Enum.concat([ |> Enum.concat([
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.25.3", only: :dev, runtime: false}, {:ex_doc, "~> 0.26.0", only: :dev, runtime: false},
{:opentelemetry, "~> 1.0.0-rc.3", only: [:dev, :test]}, {:opentelemetry, "~> 1.0.0-rc.4", only: [:dev, :test]},
{:opentelemetry_exporter, "~> 1.0.0-rc.3", only: [:dev, :test]} {:opentelemetry_exporter, "~> 1.0.0-rc.4", only: [:dev, :test]}
]) ])
end end
@ -65,7 +65,7 @@ defmodule OpentelemetryTelemetry.MixProject do
[ [
description: "Bridge library between Telemetry events and OpenTelemetry Erlang", description: "Bridge library between Telemetry events and OpenTelemetry Erlang",
build_tools: ["rebar3", "mix"], build_tools: ["rebar3", "mix"],
files: ~w(lib mix.exs README.md LICENSE CODEOWNERS rebar.config rebar.lock VERSION src), files: ~w(lib mix.exs README.md LICENSE rebar.config rebar.lock VERSION src),
licenses: ["Apache-2.0"], licenses: ["Apache-2.0"],
links: %{ links: %{
"GitHub" => "GitHub" =>

View File

@ -5,20 +5,22 @@
"ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"}, "ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"}, "earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"},
"earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"}, "earmark_parser": {:hex, :earmark_parser, "1.4.18", "e1b2be73eb08a49fb032a0208bf647380682374a725dfb5b9e510def8397f6f2", [:mix], [], "hexpm", "114a0e85ec3cf9e04b811009e73c206394ffecfcc313e0b346de0d557774ee97"},
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"}, "elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"}, "ex_doc": {:hex, :ex_doc, "0.26.0", "1922164bac0b18b02f84d6f69cab1b93bc3e870e2ad18d5dacb50a9e06b542a3", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2775d66e494a9a48355db7867478ffd997864c61c65a47d31c4949459281c78d"},
"gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"}, "gproc": {:hex, :gproc, "0.8.0", "cea02c578589c61e5341fce149ea36ccef236cc2ecac8691fba408e7ea77ec2f", [:rebar3], [], "hexpm", "580adafa56463b75263ef5a5df4c86af321f68694e7786cb057fd805d1e2a7de"},
"grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"}, "grpcbox": {:hex, :grpcbox, "0.14.0", "3eb321bcd2275baf8b54cf381feb7b0559a50c02544de28fda039c7f2f9d1a7a", [:rebar3], [{:acceptor_pool, "~>1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~>0.11.0", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~>0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~>0.8.0", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "e24159b7b6d3f9869bbe528845c0125fed2259366ba908fd04a1f45fe81d0660"},
"hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"}, "hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"},
"opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.3", "d2698bee882c354274563ee85d097bb736a9adb8d8ed376a4deea0cd3a14bb31", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "c9105933df0d783d94cf08d79206eb8d6578abc0bcbd498d0b497ec62a4e30a8"}, "opentelemetry": {:hex, :opentelemetry, "1.0.0-rc.4", "1d4ae91e097152798b85844e85976e5c81f93873788fad04871bfeb939162664", [:rebar3], [{:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "b7f6278754ad4f51d7599f1f1213755e599834f34cb4d5843f70f3df8477ca2d"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.3.1", "d183663c178f317a109a267b3c3664d09db22829a4d4eea8d9af46ed3e5bee05", [:mix, :rebar3], [], "hexpm", "4b836cec1b531080c310fa54afca6e523984a1f6c1aeb5d4da537dad9e309ce9"}, "opentelemetry_api": {:hex, :opentelemetry_api, "1.0.0-rc.4", "13fb20b8800149ce52daa8fb793c1a45b826cc4bd0d5bc7e8a00cab46285cbe6", [:mix, :rebar3], [], "hexpm", "29c5bf7d5c40c4b9816906277beb2438e6737073721c75398465b1acd1b56b06"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.3", "76f5657d4c94a12003d9ed2c8da1023c815e98f5553184dbb0cdaeec76db676d", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.3", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.3", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "267f0e4c3f1f5557cc7ad6ac71d66b8eaf7b3b56fde942c21f8a0bc96174fe1e"}, "opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.0.0-rc.4", "c614400fdfb3616bd6607b8b26348f23f2d4b96621af2b4f585e75618528ffd3", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.0.0-rc.4", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.0.0-rc.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.11", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "df303b2b9829b1896f670ca2d1ccd1d32fb44e66558091d0584033276e674465"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"},
"telemetry_registry": {:hex, :telemetry_registry, "0.3.0", "6768f151ea53fc0fbca70dbff5b20a8d663ee4e0c0b2ae589590e08658e76f1e", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "492e2adbc609f3e79ece7f29fec363a97a2c484ac78a83098535d6564781e917"}, "telemetry_registry": {:hex, :telemetry_registry, "0.3.0", "6768f151ea53fc0fbca70dbff5b20a8d663ee4e0c0b2ae589590e08658e76f1e", [:mix, :rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "492e2adbc609f3e79ece7f29fec363a97a2c484ac78a83098535d6564781e917"},
"tls_certificate_check": {:hex, :tls_certificate_check, "1.11.0", "609dcd503f31170f0799dac380eb0e086388cf918fc769aaa60ddd6bbf575218", [:rebar3], [{:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "4ab962212ef7c87482619cb298e1fe06e047b57f0bd58cc417b3b299eb8d036e"},
} }

View File

@ -1,6 +1,6 @@
{erl_opts, [debug_info]}. {erl_opts, [debug_info]}.
{deps, [ {deps, [
{opentelemetry_api, "~> 1.0.0-rc.3"}, {opentelemetry_api, "~> 1.0.0-rc.4"},
{telemetry, "~> 1.0"}, {telemetry, "~> 1.0"},
{telemetry_registry, "~> 0.3.0"} {telemetry_registry, "~> 0.3.0"}
]}. ]}.
@ -16,8 +16,8 @@
{subpackages, true}]}]}, {subpackages, true}]}]},
{test, [{erl_opts, [nowarn_export_all]}, {test, [{erl_opts, [nowarn_export_all]},
{deps, [ {deps, [
{opentelemetry, "~> 1.0.0-rc.3"}, {opentelemetry, "~> 1.0.0-rc.4"},
{opentelemetry_exporter, "~> 1.0.0-rc.3"}, {opentelemetry_exporter, "~> 1.0.0-rc.4"},
{test_app, "~> 0.1"} {test_app, "~> 0.1"}
]}, ]},
{paths, ["src", "test/support"]}, {paths, ["src", "test/support"]},

View File

@ -1,14 +1,14 @@
{"1.2.0", {"1.2.0",
[{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.0.0-rc.3.1">>},0}, [{<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.0.0-rc.4">>},0},
{<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.0.0">>},0}, {<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.0.0">>},0},
{<<"telemetry_registry">>,{pkg,<<"telemetry_registry">>,<<"0.3.0">>},0}]}. {<<"telemetry_registry">>,{pkg,<<"telemetry_registry">>,<<"0.3.0">>},0}]}.
[ [
{pkg_hash,[ {pkg_hash,[
{<<"opentelemetry_api">>, <<"D183663C178F317A109A267B3C3664D09DB22829A4D4EEA8D9AF46ED3E5BEE05">>}, {<<"opentelemetry_api">>, <<"13FB20B8800149CE52DAA8FB793C1A45B826CC4BD0D5BC7E8A00CAB46285CBE6">>},
{<<"telemetry">>, <<"0F453A102CDF13D506B7C0AB158324C337C41F1CC7548F0BC0E130BBF0AE9452">>}, {<<"telemetry">>, <<"0F453A102CDF13D506B7C0AB158324C337C41F1CC7548F0BC0E130BBF0AE9452">>},
{<<"telemetry_registry">>, <<"6768F151EA53FC0FBCA70DBFF5B20A8D663EE4E0C0B2AE589590E08658E76F1E">>}]}, {<<"telemetry_registry">>, <<"6768F151EA53FC0FBCA70DBFF5B20A8D663EE4E0C0B2AE589590E08658E76F1E">>}]},
{pkg_hash_ext,[ {pkg_hash_ext,[
{<<"opentelemetry_api">>, <<"4B836CEC1B531080C310FA54AFCA6E523984A1F6C1AEB5D4DA537DAD9E309CE9">>}, {<<"opentelemetry_api">>, <<"29C5BF7D5C40C4B9816906277BEB2438E6737073721C75398465B1ACD1B56B06">>},
{<<"telemetry">>, <<"73BC09FA59B4A0284EFB4624335583C528E07EC9AE76ACA96EA0673850AEC57A">>}, {<<"telemetry">>, <<"73BC09FA59B4A0284EFB4624335583C528E07EC9AE76ACA96EA0673850AEC57A">>},
{<<"telemetry_registry">>, <<"492E2ADBC609F3E79ECE7F29FEC363A97A2C484AC78A83098535D6564781E917">>}]} {<<"telemetry_registry">>, <<"492E2ADBC609F3E79ECE7F29FEC363A97A2C484AC78A83098535D6564781E917">>}]}
]. ].

View File

@ -38,7 +38,7 @@ trace_application(Application, _Opts) ->
-spec start_telemetry_span(atom(), opentelemetry:span_name(), telemetry:event_metadata(), otel_span:start_opts()) -> opentelemetry:span_ctx(). -spec start_telemetry_span(atom(), opentelemetry:span_name(), telemetry:event_metadata(), otel_span:start_opts()) -> opentelemetry:span_ctx().
start_telemetry_span(TracerId, SpanName, EventMetadata, Opts) -> start_telemetry_span(TracerId, SpanName, EventMetadata, Opts) ->
ParentCtx = otel_tracer:current_span_ctx(), ParentCtx = otel_tracer:current_span_ctx(),
Tracer = opentelemetry:get_tracer(TracerId), Tracer = opentelemetry:get_application_tracer(TracerId),
Ctx = otel_tracer:start_span(Tracer, SpanName, Opts), Ctx = otel_tracer:start_span(Tracer, SpanName, Opts),
otel_tracer:set_current_span(Ctx), otel_tracer:set_current_span(Ctx),
_ = store_ctx({ParentCtx, Ctx}, TracerId, EventMetadata), _ = store_ctx({ParentCtx, Ctx}, TracerId, EventMetadata),

View File

@ -29,7 +29,6 @@ init_per_testcase(_, Config) ->
{ok, _} = application:ensure_all_started(opentelemetry_telemetry), {ok, _} = application:ensure_all_started(opentelemetry_telemetry),
otel_batch_processor:set_exporter(otel_exporter_pid, self()), otel_batch_processor:set_exporter(otel_exporter_pid, self()),
otel_telemetry:trace_application(test_app), otel_telemetry:trace_application(test_app),
opentelemetry:register_tracer(test_tracer, "0.1.0"),
Config. Config.
end_per_testcase(_, Config) -> end_per_testcase(_, Config) ->
@ -64,7 +63,7 @@ telemetry_span_handling(_Config) ->
successful_span_listener(Name) -> successful_span_listener(Name) ->
receive receive
{span, #span{name=Name,attributes=Attributes,parent_span_id=ParentId,span_id=Id}} -> {span, #span{name=Name,parent_span_id=ParentId,span_id=Id}} ->
{Id, ParentId} {Id, ParentId}
after after
5000 -> 5000 ->
@ -75,7 +74,7 @@ exception_span_listener(Name) ->
receive receive
{span, #span{name=Name,events=Events,status=Status,parent_span_id=ParentId,span_id=Id}} -> {span, #span{name=Name,events=Events,status=Status,parent_span_id=ParentId,span_id=Id}} ->
?assertEqual({status,error,<<"badarg">>}, Status), ?assertEqual({status,error,<<"badarg">>}, Status),
?assertEqual(1, erlang:length(Events)), ?assertEqual(1, erlang:length(otel_events:list(Events))),
{Id, ParentId} {Id, ParentId}
after after
5000 -> 5000 ->