ScoutApm.Instruments.TeslaTelemetry (scout_apm v2.0.0)

Copy Markdown

Telemetry handler for Tesla HTTP client instrumentation.

Attaches to Tesla telemetry events to track external HTTP requests:

  • HTTP requests appear as "HTTP" type layers (External Services)
  • Tracks URL, HTTP method, and response status code

Prerequisites

Your Tesla client must include the Telemetry middleware. Add it to your client:

defmodule MyApp.ApiClient do
  use Tesla

  plug Tesla.Middleware.Telemetry
  plug Tesla.Middleware.BaseUrl, "https://api.example.com"
  # ... other middleware
end

Important: Place Tesla.Middleware.Telemetry as close as possible to the end of the middleware stack to ensure accurate timing measurements.

Usage

In your application's start/2 function:

def start(_type, _args) do
  ScoutApm.Instruments.TeslaTelemetry.attach()
  # ... rest of supervision tree
end

What's Tracked

  • Operation: HTTP/{method} (e.g., "HTTP/GET", "HTTP/POST")
  • URL: The full URL of the request (sanitized)
  • Status Code: The HTTP response status code

Configuration

Requests to Scout APM's own endpoints are automatically excluded from tracking.

Summary

Functions

Attaches telemetry handlers for Tesla HTTP request events.

Detaches the telemetry handlers. Useful for testing.

Functions

attach()

Attaches telemetry handlers for Tesla HTTP request events.

Call this once during application startup.

detach()

Detaches the telemetry handlers. Useful for testing.

handle_event(arg1, measurements, metadata, config)