Tesla.StatsD (tesla_statsd v0.4.0)
This middleware sends histogram stats to Datadog for every outgoing request. The sent value is response time in milliseconds.
Metric name is configurable and defaults to "http.request". The middleware also sends tags:
http_status
- HTTP status code.http_status_family
(2xx, 4xx, 5xx) - HTTP status familyhttp_host
- The host request has been sent to
Tags have "http" in their names to avoid collisions with default tags sent by Datadog StatsD agent.
configuration
Configuration
:backend
- StatsD backend module. Defaults toTesla.StatsD.Backend.ExStatsD
. A backend must implementTesla.StatsD.Backend
behaviour.Statix
backends are supported by default, just provide a module name that usesStatix
(use Statix
).:metric
- Metric name. Can be ether string or function(Tesla.Env.t -> String.t)
.:metric_type
- Metric type. Can be:histogram
(default) or:gauge
. See Datadog documentation.:tags
- List of additional tags. Can be either list or function(Tesla.Env.t -> [String.t])
.:sample_rate
- Limit how often the metric is collected (default: 1)
usage-with-tesla
Usage with Tesla
defmodule AccountsClient do
use Tesla
plug Tesla.StatsD,
metric: "external.request",
tags: ["service:accounts"],
backend: MyApp.Statix
end
Link to this section Summary
Functions
Callback implementation for Tesla.Middleware.call/3
.
Link to this section Functions
Link to this function
call(env, next, opts)
Callback implementation for Tesla.Middleware.call/3
.