Skip to content

k6 extension to generate OpenTelemetry signals for load testing

License

Notifications You must be signed in to change notification settings

thmshmm/xk6-opentelemetry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xk6-opentelemetry logo xk6-opentelemetry

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.

Features

  • Generate
    • ExportLogsServiceRequest
    • ExportMetricsServiceRequest (Types: gauge, sum, histogram)
    • ExportTraceServiceRequest
  • Set resource attributes

Usage

Docker

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

Local build

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

Testing

Local environment

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

Examples

Execute:

./k6 run examples/<SCRIPT>.js

Run all examples:

task run-examples