szgen is a basic CLI tool for generating synthetic OpenTelemetry data inspired by tools like telemetrygen or dogshell. The motivation is that I needed to quickly model different metric generation scenarios and test them with different OTel collector setups (mostly for component development), so this started as mini script and eventually it got a little bigger.
At the moment this CLI only supports metrics data. It supports Counter, Gauge, Histogram (+Exponential Histogram), and UpDownCounter metric types with configurable value generators. Eventually I might add other signal types.
Run go install or clone and just install
git clone https://github.com/neonmei/szgen.git
cd szgen
just installGenerate a simple counter by executing an imperative or one-off command. Shorthand: szgen m c [flags...]
szgen metrics counter --name http_requests_total --rate 1s --count 10 --value 1Run a predefined routine from YAML. Shorthand: szgen r [flags...]
szgen run --config examples/basic-counter.yamlszgen [global-flags] <telemetry signal> [command-flags and/or subcommands]
--executor, -e: Execution strategy -serialorconcurrent(default:serial)--max-concurrency, -j: Maximum concurrent tasks for concurrent executor (0 = unlimited)
Each type is defined as a sub-command like so:
szgen metrics counter --name <name> --rate <duration> --count <number> [flags]szgen metrics gauge --name <name> --rate <duration> --count <number> [flags]szgen metrics histogram --name <name> --rate <duration> --count <number> [flags]szgen metrics updowncounter --name <name> --rate <duration> --count <number> [flags]--type: Value type - int64 or float64 (default: “float64”)--generator: Strategy to use when generating values--value: Generator configuration value--description: Metric description--unit: Metric unit--attributes: Comma-separated key=value pairs
These can be configured with `–value` using a single or more optional values (as in the case of `sine` generator).
| Generator | Description | Value Format | Example |
|---|---|---|---|
| constant | Fixed value | Single number | --value 42 |
| random | Random values | max or max,min | --value 100,1 |
| step | Increasing or decreasing value | initial,step (positive=increasing, negative=decreasing) | --value 10,2 or --value 100,-5 |
| sine | Sine wave pattern | amplitude,b,vertical_shift,horizontal_shift | --value 50,10,100,0 |
| sequence | Predefined sequence of numbers | Comma-separated values | --value 1,2,3,5,8 |
szgen supports two execution strategies for running multiple metric generation tasks:
Tasks execute sequentially, one after another. This is the default mode and provides predictable execution order.
szgen run --config config.yaml --executor serialAll signal tasks execute concurrently using goroutines. By default concurrency is unbounded but can be optionally bounded to a specific concurrency level. Failed tasks are logged and stop execution.
szgen run --config config.yaml --executor concurrent --max-concurrency 4There are 2 main configurations:
otelconfconfiguration: is a emerging standard that allows configuring OpenTelemetry SDKszgen: is a config file for this tool that allows to configure and run the same tasks repeatedly with therunCLI command.
To get a glance of what otelconf allows configuring, we can take a look at the full config in opentelemetry-go-contrib testdata: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/otelconf/testdata/v1.0.0.yaml
The defaults if we don’t tune it is something like the following:
file_format: "1.0-rc.2"
disabled: false
log_level: "info"
meter_provider:
readers:
- periodic:
interval: 1000
timeout: 1000
exporter:
otlp_grpc:
endpoint: "http://127.0.0.1:4317"
encoding: "protobuf"
compression: "gzip"
insecure: true
timeout: 1000
temporality_preference: "delta"
default_histogram_aggregation: "base2_exponential_bucket_histogram"
views:
- selector:
instrument_type: "histogram"
stream:
aggregation:
base2_exponential_bucket_histogram:
max_size: 100
max_scale: 10
no_min_max: false
resource:
attributes:
- name: "service.name"
value: "szgen"
type: "string"
- name: "service.version"
value: "0.1.0"
type: "string"This OpenTelemetry configuration will be sourced from a couple places (from less to high priority):
- defaults shown above
- ~~/.config/szgen/opentelemetry.yaml~
- the
szgenconfig has aopentelemetrykey which will be used as strictotelconf
For convenience, there is some minimal overlaying logic of global configs (1,2) and szgen config. This allows for example setting only the resource attributes while avoiding repeating connection parameters all over the place (these can be in a global location).
For counting 1 each second (constant generator), five times :
metrics:
tasks:
- name: http.server.request.total
kind: counter
count: 5opentelemetry:
resource:
attributes:
- name: service.name
value: "my-service"
- name: service.version
value: "1.0.0"
type: string
- name: environment
value: "testing"
metrics:
tasks:
- name: "http_requests_total"
kind: "counter"
type: "int64"
rate: "1s"
count: 100
value: "1"
generator: "constant"
attributes:
service: "web-server"
method: "GET"
executor:
strategy: "concurrent"
params:
max_concurrency: 4The examples/ directory contains various configuration examples:
basic-counter.yaml: Simple counter metricbasic-gauge.yaml: Gauge metric examplebasic-histogram-views-demo.yaml: Histogram with exponential bucketsbasic-file-export.yaml: File export examplebasic-primes.yaml: Sequence generator example (emits a gauge sequence of primes)minimal-counter.yaml: Minimal configuration example to show how much is optional in config filessystem-monitoring.yaml: System monitoring metricshttp-service-monitoring.yaml: HTTP service metricsdatabase-monitoring.yaml: Database performance metricsmessaging-monitoring.yaml: Message queue metrics
