O
OTLP metrics
Observability collectors availableExport/collect metrics via OTLP to an OpenTelemetry collector.
$ loadr plugin install otlp-metrics
# Stream loadr's live metrics into an OpenTelemetry collector, driven by the
# `loadr-plugin-otlp-metrics` native OUTPUT plugin.
#
# An output plugin follows the same start / on_snapshot / finish lifecycle as
# the built-in exporters: loadr calls `start(config)` once, hands the plugin a
# metric snapshot roughly once a second during the run, then `finish(summary)`
# at the end. This plugin converts each snapshot's series into an OTLP
# `ExportMetricsServiceRequest` and POSTs it to the collector's `/v1/metrics`
# endpoint over OTLP/HTTP. The body is protobuf by default (or JSON via
# `encoding: json`); the transport is pure hyper + hyper-rustls, so nothing
# beyond outbound HTTP(S) to the collector is required.
#
# Counters (e.g. `http_reqs`) become monotonic OTLP Sums; gauges (e.g. `vus`)
# and rates (e.g. `checks`) become Gauges; trends (e.g. `http_req_duration`)
# emit one gauge per published quantile — `http_req_duration.p95`, `.p99`,
# `.avg`, `.max`. Every data point carries the run's `run_id` plus the series'
# tags as attributes so concurrent runs stay separable in a shared backend.
#
# Build + install the plugin, then run:
# cargo build -p loadr-plugin-otlp-metrics --release
# mkdir -p dist && cp plugins/loadr-plugin-otlp-metrics/plugin.toml dist/ \
# && cp target/release/libloadr_plugin_otlp_metrics.so dist/
# loadr plugin install dist
# OTLP_ENDPOINT=http://localhost:4318 loadr run examples/plugins/otlp-metrics.yaml
name: otlp-export
description: Export live loadr metrics to an OpenTelemetry collector over OTLP/HTTP
defaults:
http:
base_url: https://api.example.com
scenarios:
browse:
executor: ramping-vus
stages:
- { target: 20, duration: 30s }
- { target: 20, duration: 2m }
- { target: 0, duration: 30s }
flow:
- request: { name: list, url: /api/v1/items }
- request:
name: detail
url: /api/v1/items/1
checks: [ { type: status, equals: 200 } ]
outputs:
# Resolve `otlp-metrics` by name from the plugins dir (after `loadr plugin install`).
- type: plugin
name: otlp-metrics
config:
# Required. Base URL of the OTLP/HTTP collector — point at the 4318 port,
# NOT the 4317 gRPC port. The plugin appends `/v1/metrics`. Supplied per
# run from the environment so it stays out of the plan file.
endpoint: ${env.OTLP_ENDPOINT}
# Wire encoding: `protobuf` (default, application/x-protobuf) or `json`.
encoding: protobuf
# `service.name` resource attribute on every exported metric.
service_name: checkout
# Extra OTLP resource attributes attached to every metric.
resource_attributes:
deployment.environment: staging
# Extra HTTP headers — typically an auth header for a hosted collector.
# Set from the environment, never hard-coded.
headers:
Authorization: Bearer ${env.OTLP_TOKEN}
# Per-request timeout and 5xx retry budget (exponential backoff).
timeout_ms: 10000
max_retries: 3
thresholds:
http_req_failed: [ "rate<0.02" ]
http_req_duration: [ "p(95)<600" ]
A real run: install from the signed index, then watch the plugin work.
A runtime plugin, never in the binary
Installing pulls a per-platform driver from the signed index, verifies its SHA-256 and checks its ABI before it ever loads. Remove it any time with loadr plugin remove otlp-metrics.