Skip to content

neonmei/szgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

szgen - Synthetic Telemetry Generator

Overview

./docs/sz.png

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.

Installation

Build from Source

Run go install or clone and just install

git clone https://github.com/neonmei/szgen.git
cd szgen
just install

Quick Start

Basic Counter Example

Generate 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 1

Using Configuration File

Run a predefined routine from YAML. Shorthand: szgen r [flags...]

szgen run --config examples/basic-counter.yaml

Usage

Command Structure

szgen [global-flags] <telemetry signal> [command-flags and/or subcommands]

Global Flags

Execution Configuration

  • --executor, -e: Execution strategy - serial or concurrent (default: serial)
  • --max-concurrency, -j: Maximum concurrent tasks for concurrent executor (0 = unlimited)

Metric Commands

Each type is defined as a sub-command like so:

Counter

szgen metrics counter --name <name> --rate <duration> --count <number> [flags]

Gauge

szgen metrics gauge --name <name> --rate <duration> --count <number> [flags]

Histogram

szgen metrics histogram --name <name> --rate <duration> --count <number> [flags]

UpDownCounter

szgen metrics updowncounter --name <name> --rate <duration> --count <number> [flags]

Common Metric 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

Value Generators

These can be configured with `–value` using a single or more optional values (as in the case of `sine` generator).

GeneratorDescriptionValue FormatExample
constantFixed valueSingle number--value 42
randomRandom valuesmax or max,min--value 100,1
stepIncreasing or decreasing valueinitial,step (positive=increasing, negative=decreasing)--value 10,2 or --value 100,-5
sineSine wave patternamplitude,b,vertical_shift,horizontal_shift--value 50,10,100,0
sequencePredefined sequence of numbersComma-separated values--value 1,2,3,5,8

Execution Modes

szgen supports two execution strategies for running multiple metric generation tasks:

Serial Execution (default)

Tasks execute sequentially, one after another. This is the default mode and provides predictable execution order.

szgen run --config config.yaml --executor serial

Concurrent Execution

All 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 4

Configuration File Format

There are 2 main configurations:

  1. otelconf configuration: is a emerging standard that allows configuring OpenTelemetry SDK
  2. szgen: is a config file for this tool that allows to configure and run the same tasks repeatedly with the run CLI command.

otelconf: configuring OpenTelemetry SDK

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):

  1. defaults shown above
  2. ~~/.config/szgen/opentelemetry.yaml~
  3. the szgen config has a opentelemetry key which will be used as strict otelconf

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).

szgen: minimal example

For counting 1 each second (constant generator), five times :

metrics:
  tasks:
  - name: http.server.request.total
    kind: counter
    count: 5

szgen: basic Structure

opentelemetry:
  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: 4

Examples

The examples/ directory contains various configuration examples:

  • basic-counter.yaml: Simple counter metric
  • basic-gauge.yaml: Gauge metric example
  • basic-histogram-views-demo.yaml: Histogram with exponential buckets
  • basic-file-export.yaml: File export example
  • basic-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 files
  • system-monitoring.yaml: System monitoring metrics
  • http-service-monitoring.yaml: HTTP service metrics
  • database-monitoring.yaml: Database performance metrics
  • messaging-monitoring.yaml: Message queue metrics

About

szgen is a synthetic OpenTelemetry generator inspired by telemetrygen.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors