Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F114327
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/tesla/middleware/telemetry.ex b/lib/tesla/middleware/telemetry.ex
index 1d1f357..9ffac7a 100644
--- a/lib/tesla/middleware/telemetry.ex
+++ b/lib/tesla/middleware/telemetry.ex
@@ -1,30 +1,32 @@
-defmodule Tesla.Middleware.Telemetry do
- @behaviour Tesla.Middleware
+if Code.ensure_loaded?(:telemetry) do
+ defmodule Tesla.Middleware.Telemetry do
+ @behaviour Tesla.Middleware
- @moduledoc """
- Send the request time and meta-information through telemetry.
+ @moduledoc """
+ Send the request time and meta-information through telemetry.
- ### Example usage
- ```
- defmodule MyClient do
- use Tesla
+ ### Example usage
+ ```
+ defmodule MyClient do
+ use Tesla
- plug Tesla.Middleware.Telemetry
+ plug Tesla.Middleware.Telemetry
- end
+ end
- :telemetry.attach("my-tesla-telemetry", [:tesla, :request], fn event, time, meta, config ->
- # Do something with the event
- end)
- ```
+ :telemetry.attach("my-tesla-telemetry", [:tesla, :request], fn event, time, meta, config ->
+ # Do something with the event
+ end)
+ ```
- Please check the [telemetry](https://hexdocs.pm/telemetry/) for the further usage.
- """
+ Please check the [telemetry](https://hexdocs.pm/telemetry/) for the further usage.
+ """
- @doc false
- def call(env, next, _opts) do
- {time, res} = :timer.tc(Tesla, :run, [env, next])
- :telemetry.execute([:tesla, :request], %{request_time: time}, %{result: res})
- res
+ @doc false
+ def call(env, next, _opts) do
+ {time, res} = :timer.tc(Tesla, :run, [env, next])
+ :telemetry.execute([:tesla, :request], %{request_time: time}, %{result: res})
+ res
+ end
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 26, 3:55 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40190
Default Alt Text
(1 KB)
Attached To
Mode
R28 tesla
Attached
Detach File
Event Timeline
Log In to Comment