The xk6-opentelemetry project is a k6 extension that enables k6 users to generate random OpenTelemetry signals (metrics, logs, traces) for testing purposes.
Check the examples directory which contains some scripts to get started.
- Generate
- ExportLogsServiceRequest
- ExportMetricsServiceRequest (Types: gauge, sum, histogram)
- ExportTraceServiceRequest
- Set resource attributes
The easiest way to get started is to build the provided Docker image and run k6 scripts inside the container.
Build the image:
docker build -t xk6-opentelemetry .
Run a local k6 script:
docker run --rm -i xk6-opentelemetry run - <my-script.js
As the testing environment and scripts rely on sending messages to Kafka, the extension xk6-kafka needs to be integrated as well when creating the k6 binary.
Create the binary:
git clone [email protected]:thmshmm/xk6-opentelemetry.git && cd xk6-opentelemetry
xk6 build --with xk6-opentelemetry=. --with github.com/mostafa/xk6-kafka
or use Task:
task build-k6
Start a local test environment including Kafka (Redpanda) and an instance of the OpenTelemetry Collector using Docker Compose. The OTel Collector is configured to read messages using the Kafka receiver and write all messages to STDOUT of the container.
Start:
task testing-up
Stop:
task testing-down
- test-logs.js - Create random log signals.
- test-metrics.js - Create random gauge/sum metric signals.
- test-metrics-histogram.js - Create random histogram metric signals.
- test-traces.js - Create random trace signals.
Execute:
./k6 run examples/<SCRIPT>.js
Run all examples:
task run-examples