You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cmd/telemetrygen] expose the generated span duration as a command pa… (#29116)
**Description:**
As originally proposed in #26991 before I got distracted
Exposes the duration of generated spans as a command line parameter. It
uses a `DurationVar` flag so units can be easily provided and are
automatically applied.
Example usage:
```bash
telemetrygen traces --traces 100 --otlp-insecure --span-duration 10ns # nanoseconds
telemetrygen traces --traces 100 --otlp-insecure --span-duration 10us # microseconds
telemetrygen traces --traces 100 --otlp-insecure --span-duration 10ms # milliseconds
telemetrygen traces --traces 100 --otlp-insecure --span-duration 10s # seconds
```
**Testing:**
Ran without the argument provided `telemetrygen traces --traces 1
--otlp-insecure` and seen spans publishing with the default value.
Ran again with the argument provided: `telemetrygen traces --traces 1
--otlp-insecure --span-duration 1s`
And observed the expected output:
```
Resource SchemaURL: https://opentelemetry.io/schemas/1.4.0
Resource attributes:
-> service.name: Str(telemetrygen)
ScopeSpans #0
ScopeSpans SchemaURL:
InstrumentationScope telemetrygen
Span #0
Trace ID : 8b441587ffa5820688b87a6b511d634c
Parent ID : 39faad428638791b
ID : 88f0886894bd4ee2
Name : okey-dokey
Kind : Server
Start time : 2023-11-12 02:05:07.97443 +0000 UTC
End time : 2023-11-12 02:05:08.97443 +0000 UTC
Status code : Unset
Status message :
Attributes:
-> net.peer.ip: Str(1.2.3.4)
-> peer.service: Str(telemetrygen-client)
Span #1
Trace ID : 8b441587ffa5820688b87a6b511d634c
Parent ID :
ID : 39faad428638791b
Name : lets-go
Kind : Client
Start time : 2023-11-12 02:05:07.97443 +0000 UTC
End time : 2023-11-12 02:05:08.97443 +0000 UTC
Status code : Unset
Status message :
Attributes:
-> net.peer.ip: Str(1.2.3.4)
-> peer.service: Str(telemetrygen-server)
{"kind": "exporter", "data_type": "traces", "name": "debug"}
```
**Documentation:** No documentation added.
---------
Co-authored-by: Pablo Baeyens <[email protected]>
fs.StringVar(&c.StatusCode, "status-code", "0", "Status code to use for the spans, one of (Unset, Error, Ok) or the equivalent integer (0,1,2)")
33
36
fs.BoolVar(&c.Batch, "batch", true, "Whether to batch traces")
34
37
fs.IntVar(&c.LoadSize, "size", 0, "Desired minimum size in MB of string data for each trace generated. This can be used to test traces with large payloads, i.e. when testing the OTLP receiver endpoint max receive size.")
38
+
fs.DurationVar(&c.SpanDuration, "span-duration", 123*time.Microsecond, "The duration of each generated span.")
0 commit comments