View Source Tesla.Middleware.Timeout (tesla v1.12.1)

Timeout HTTP request after X milliseconds.

Examples

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.Timeout, timeout: 2_000
end

If you are using OpenTelemetry in your project, you may be interested in using OpentelemetryProcessPropagator.Task to have a better integration using the task_module option.

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.Timeout,
    timeout: 2_000,
    task_module: OpentelemetryProcessPropagator.Task
end

Options

  • :timeout - number of milliseconds a request is allowed to take (defaults to 1000)
  • :task_module - the Task module used to spawn tasks. Useful when you want use alternatives such as OpentelemetryProcessPropagator.Task from OTEL project.