Tesla
The AppSignal for Elixir package instruments HTTP requests performed by Tesla.
Tesla is a flexible HTTP client library for Elixir. It can use multiple middlewares and adapters to modify and perform HTTP request, and it has built-in support for request telemetry.
After configuring Tesla's Telemetry middleware, AppSignal will recognize requests executed via Tesla and show them as request.tesla
events on your performance samples' Event Timeline.
In the Event Timeline, you'll see how much time Tesla spends making external API requests. This data may help inform you to move the API requests to a background job or introduce caching to help speed up performance and limit unnecessary API requests.
In the Slow API Requests performance view, you'll be able to see aggregated throughput and average times for different kinds of HTTP requests. Follow the instructions in the Path Params Grouping section in order to improve the information shown in this view.
Configuration
Add the Tesla.Middleware.Telemetry
middleware to your module or client's middleware chain, before any other middlewares:
Enhanced Grouping
By default, the AppSignal instrumentation for Tesla will group requests by the domain name they're performed against. The path of the request will not be shown in AppSignal. However, by using certain Tesla middlewares, it's possible to add more information about the request.
The following sections describe each middleware's behaviour separately, but it is also possible to use them together.
Base URL Grouping
When using the BaseUrl
middleware, the base URL provided, including its path, will be used for grouping, providing you with some additional insight into the target of the HTTP requests performed by Tesla:
In the above example, requests performed by this client will be shown in the sample's Event Timeline and in the Slow API Requests performance view as GET https://api.example.com/v2/users
, instead of just GET https://api.example.com
, providing additional information about the requests that are being performed.
Path Params Grouping
When using the PathParams
middleware, the URL given to Tesla for the request will be a template, with path parameters being passed separately:
When PathParams
is used, the URL template will be shown in AppSignal. Requests will appear as GET https://api.example.com/v2/users/:user/comments
in the sample's Event Timeline and in the Slow API Requests performance view, providing you with a detailed view of each request type that your client performs.
Disable Tesla Instrumentation
To disable the Tesla instrumentation, set the instrument_tesla
config option to false
.