Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F114173
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/test/tesla/middleware/telemetry_test.exs b/test/tesla/middleware/telemetry_test.exs
index 6986333..eab30a5 100644
--- a/test/tesla/middleware/telemetry_test.exs
+++ b/test/tesla/middleware/telemetry_test.exs
@@ -1,75 +1,75 @@
defmodule Tesla.Middleware.TelemetryTest do
use ExUnit.Case, async: true
defmodule Client do
use Tesla
plug Tesla.Middleware.Telemetry
adapter fn env ->
case env.url do
"/telemetry" -> {:ok, env}
"/telemetry_error" -> {:error, :econnrefused}
"/telemetry_exception" -> raise "some exception"
end
end
end
setup do
Application.ensure_all_started(:telemetry)
on_exit(fn ->
:telemetry.list_handlers([])
|> Enum.each(&:telemetry.detach(&1.id))
end)
:ok
end
test "events are all emitted properly" do
Enum.each(["/telemetry", "/telemetry_error"], fn path ->
:telemetry.attach("start event", [:tesla, :request, :start], &echo_event/4, %{
caller: self()
})
:telemetry.attach("stop event", [:tesla, :request, :stop], &echo_event/4, %{
caller: self()
})
:telemetry.attach("legacy event", [:tesla, :request], &echo_event/4, %{
caller: self()
})
Client.get(path)
- assert_receive {:event, [:tesla, :request, :start], %{system_time: time},
- %{env: %Tesla.Env{url: path, method: :get}}}
+ assert_receive {:event, [:tesla, :request, :start], %{system_time: _time},
+ %{env: %Tesla.Env{url: ^path, method: :get}}}
- assert_receive {:event, [:tesla, :request, :stop], %{duration: time},
- %{env: %Tesla.Env{url: path, method: :get}}}
+ assert_receive {:event, [:tesla, :request, :stop], %{duration: _time},
+ %{env: %Tesla.Env{url: ^path, method: :get}}}
- assert_receive {:event, [:tesla, :request], %{request_time: time}, %{result: result}}
+ assert_receive {:event, [:tesla, :request], %{request_time: _time}, %{result: _result}}
end)
end
test "with an exception raised" do
:telemetry.attach("with_exception", [:tesla, :request, :exception], &echo_event/4, %{
caller: self()
})
assert_raise RuntimeError, fn ->
Client.get("/telemetry_exception")
end
- assert_receive {:event, [:tesla, :request, :exception], %{duration: time},
+ assert_receive {:event, [:tesla, :request, :exception], %{duration: _time},
%{
- kind: kind,
- reason: reason,
- stacktrace: stacktrace
+ kind: _kind,
+ reason: _reason,
+ stacktrace: _stacktrace
}}
end
def echo_event(event, measurements, metadata, config) do
send(config.caller, {:event, event, measurements, metadata})
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 9:55 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40083
Default Alt Text
(2 KB)
Attached To
Mode
R28 tesla
Attached
Detach File
Event Timeline
Log In to Comment