A work in progress k6 extension to output real-time test metrics in OpenTelemetry metrics format.
Warning
It's work in progress implementation and not ready for production use.
It's worth to mention that the extension is using the OpenTelemetry Go SDK that's why it's possible to use the configuration environment variables from the SDK. However, if the K6_OTEL_*
environment variables are set, they will take precedence over the SDK configuration.
K6_OTEL_METRIC_PREFIX
- Metric prefix. Default is empty.K6_OTEL_FLUSH_INTERVAL
- How frequently to flush metrics from k6 metrics engine. Default is1s
.
K6_OTEL_EXPORT_INTERVAL
- configures the intervening time between metrics exports. Default is10s
.K6_OTEL_EXPORTER_TYPE
- metric exporter type. Default isgrpc
.K6_OTEL_HEADERS
- headers in W3C Correlation-Context format without additional semi-colon delimited metadata (i.e. "k1=v1,k2=v2"). Passes the headers to the exporter.
K6_OTEL_TLS_INSECURE_SKIP_VERIFY
- disables server certificate verification.K6_OTEL_TLS_CERTIFICATE
- path to the certificate file for TLS credentials.K6_OTEL_TLS_CLIENT_CERTIFICATE
- path to the client certificate file (must be PEM encoded data).K6_OTEL_TLS_CLIENT_KEY
- path to the client key file (must be PEM encoded data).
If TLS configuration is provided, the exporter will use it.
K6_OTEL_GRPC_EXPORTER_INSECURE
- disables client transport security for the gRPC exporter.K6_OTEL_GRPC_EXPORTER_ENDPOINT
- configures the gRPC exporter endpoint. Default islocalhost:4317
.
Tip
Also, you can use OpenTelemetry SDK configuration environment variables.
K6_OTEL_HTTP_EXPORTER_INSECURE
- disables client transport security for the HTTP exporter.K6_OTEL_HTTP_EXPORTER_ENDPOINT
- configures the HTTP exporter endpoint. Default islocalhost:4318
.K6_OTEL_HTTP_EXPORTER_URL_PATH
- configures the HTTP exporter path. Default is/v1/metrics
.
Tip
Also, you can use OpenTelemetry SDK configuration environment variables.
To build a k6
binary with this extension, first ensure you have the prerequisites:
- Go toolchain
- Git
- xk6
make build
This will result in a k6
binary in the current directory.
- You could run a local environment with OpenTelemetry collector (Grafana Alloy), Prometheus backend and Grafana (http://localhost:3000/):
docker-compose up -d
- Run with the just build `k6:
K6_OTEL_GRPC_EXPORTER_INSECURE=true K6_OTEL_METRIC_PREFIX=k6_ ./k6 run --tag testid=1 -o xk6-opentelemetry examples/script.js
- Open Grafana http://localhost:3000/ and navigate to the
k6 OpenTelemetry Prometheus
dashboard.