$npx -y skills add ollygarden/opentelemetry-agent-skills --skill otel-telemetrygenConstruct telemetrygen commands for generating synthetic OpenTelemetry traces, metrics, and logs via OTLP. Use this skill whenever the user wants to generate test telemetry, load test a collector or backend, create synthetic OTLP data, send sample traces/metrics/logs to an endpoi
| 1 | # Telemetrygen |
| 2 | |
| 3 | Generate synthetic OpenTelemetry telemetry with `telemetrygen` from [opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/cmd/telemetrygen). |
| 4 | |
| 5 | Upstream metadata currently marks the traces, metrics, and logs subcommands as alpha. |
| 6 | |
| 7 | ## Quick orientation |
| 8 | |
| 9 | `telemetrygen` has three subcommands -- `traces`, `metrics`, `logs` -- each exporting via OTLP to a collector or backend. The default transport is gRPC on port 4317; add `--otlp-http` to switch to HTTP on port 4318. |
| 10 | |
| 11 | Every command needs at least a subcommand and typically `--otlp-insecure` for local development (TLS is on by default). |
| 12 | |
| 13 | ## Workflow |
| 14 | |
| 15 | 1. **Pick the signal** -- `traces`, `metrics`, or `logs`. |
| 16 | 2. **Set the endpoint** -- defaults to `localhost:4317` (gRPC) or `localhost:4318` (HTTP). Use `--otlp-endpoint` to override. |
| 17 | 3. **Choose count or duration** -- use `--traces`/`--metrics`/`--logs` for a fixed count per worker, or `--duration` for time-based generation. Duration overrides count when both are set. |
| 18 | 4. **Control throughput** -- for metrics and logs, total record rate = `--workers` x `--rate`. For traces, `--rate` applies to every span, so approximate trace rate = `workers x rate / (1 + max(1, child-spans))`. `--rate` defaults to `1` metric/span/log per second per worker; set `--rate 0` for unbounded max-speed generation (dangerous against real backends). |
| 19 | 5. **Add identity and attributes** -- `--service` sets the service name; `--otlp-attributes` adds resource-level attributes; `--telemetry-attributes` adds span/metric/log-level attributes. |
| 20 | 6. **Review the anti-patterns** below before running against shared or production infrastructure. |
| 21 | |
| 22 | ## Common flags (all subcommands) |
| 23 | |
| 24 | See `references/flags.md` for the full flag reference. Key flags: |
| 25 | |
| 26 | | Flag | Default | Purpose | |
| 27 | |------|---------|---------| |
| 28 | | `--otlp-endpoint` | `localhost:4317` / `4318` | Target endpoint | |
| 29 | | `--otlp-http` | `false` | Switch to HTTP transport | |
| 30 | | `--otlp-insecure` | `false` | Disable TLS | |
| 31 | | `--workers` | `1` | Concurrent goroutines | |
| 32 | | `--rate` | `1` | Metrics/spans/logs per sec/worker (`0` = unlimited) | |
| 33 | | `--duration` | `0` | Time-based generation (`5s`, `1m`, `inf`) | |
| 34 | | `--timeout` | `10s` | Max time to wait for signals to reach destination | |
| 35 | | `--service` | `"telemetrygen"` | Service name | |
| 36 | | `--otlp-attributes` | -- | Resource attributes (repeatable) | |
| 37 | | `--telemetry-attributes` | -- | Telemetry-level attributes (repeatable) | |
| 38 | | `--otlp-header` | -- | Custom request headers (repeatable) | |
| 39 | | `--batch` / `--batch-size` | `true` / `100` | Batching controls | |
| 40 | |
| 41 | ### Attribute value format |
| 42 | |
| 43 | ``` |
| 44 | --otlp-attributes 'key="string-value"' # String (quotes must reach telemetrygen) |
| 45 | --otlp-attributes key=true # Boolean |
| 46 | --otlp-attributes key=123 # Integer |
| 47 | --otlp-attributes 'key=["val1","val2"]' # Slice (all elements same type) |
| 48 | ``` |
| 49 | |
| 50 | Resource attributes (`--otlp-attributes`) attach to the Resource; telemetry attributes (`--telemetry-attributes`) attach to the individual span, data point, or log record. Mixing them up is a common mistake. |
| 51 | |
| 52 | ## Traces |
| 53 | |
| 54 | ```bash |
| 55 | telemetrygen traces --otlp-insecure --traces 100 |
| 56 | ``` |
| 57 | |
| 58 | Key trace flags: `--child-spans` (default and minimum effective value 1), `--span-duration` (default 123us), `--status-code` (Unset/Error/Ok), `--span-links`. |
| 59 | |
| 60 | ### Trace recipes |
| 61 | |
| 62 | ```bash |
| 63 | # Error spans for testing error-detection pipelines |
| 64 | telemetrygen traces --otlp-insecure --traces 50 --status-code Error |
| 65 | |
| 66 | # Deep traces with 5 child spans |
| 67 | telemetrygen traces --otlp-insecure --traces 20 --child-spans 5 |
| 68 | |
| 69 | # Custom service with attributes |
| 70 | telemetrygen traces --otlp-insecure --traces 10 \ |
| 71 | --service "checkout-service" \ |
| 72 | --otlp-attributes 'deployment.environment="staging"' \ |
| 73 | --telemetry-attributes 'http.method="POST"' |
| 74 | ``` |
| 75 | |
| 76 | ## Metrics |
| 77 | |
| 78 | ```bash |
| 79 | telemetrygen metrics --otlp-insecure --metrics 100 |
| 80 | ``` |
| 81 | |
| 82 | Key metric flags: `--metric-type` (Gauge/Sum/Histogram/ExponentialHistogram), `--otlp-metric-name` (default "gen"), `--aggregation-temporality` (cumulative/delta), `--trace-id`/`--span-id` (exemplar linking). |
| 83 | |
| 84 | ### Metric recipes |
| 85 | |
| 86 | ```bash |
| 87 | # Histogram with a meaningful name |
| 88 | telemetrygen metrics --otlp-insecure --metrics 50 \ |
| 89 | --metric-type Histogram --otlp-metric-name "http.server.request.duration" |
| 90 | |
| 91 | # Delta sums for 30 seconds |
| 92 | telemetrygen metrics --otlp-insecure --duration 30s \ |
| 93 | --metr |