Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmd/telemetrygen] expose the generated span duration as a command pa… #29116

Merged
merged 6 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[cmd/telemetrygen]: run linter over changes
  • Loading branch information
jmsnll committed Nov 12, 2023
commit d13ed764539a8e7a0c2f9688ccadbdd0200e9e84
6 changes: 3 additions & 3 deletions cmd/telemetrygen/internal/traces/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package traces

import (
"time"
"time"

"github.com/spf13/pflag"

Expand All @@ -20,7 +20,7 @@ type Config struct {
StatusCode string
Batch bool
LoadSize int
SpanDuration time.Duration
SpanDuration time.Duration
}

// Flags registers config flags.
Expand All @@ -35,5 +35,5 @@ func (c *Config) Flags(fs *pflag.FlagSet) {
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)")
fs.BoolVar(&c.Batch, "batch", true, "Whether to batch traces")
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.")
fs.DurationVar(&c.SpanDuration, "span-duration", 123*time.Microsecond, "The duration of each generated span.")
fs.DurationVar(&c.SpanDuration, "span-duration", 123*time.Microsecond, "The duration of each generated span.")
}
2 changes: 1 addition & 1 deletion cmd/telemetrygen/internal/traces/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func Run(c *Config, logger *zap.Logger) error {
wg: &wg,
logger: logger.With(zap.Int("worker", i)),
loadSize: c.LoadSize,
spanDuration: c.SpanDuration,
spanDuration: c.SpanDuration,
}

go w.simulateTraces(telemetryAttributes)
Expand Down
14 changes: 7 additions & 7 deletions cmd/telemetrygen/internal/traces/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type worker struct {
totalDuration time.Duration // how long to run the test for (overrides `numTraces`)
limitPerSecond rate.Limit // how many spans per second to generate
wg *sync.WaitGroup // notify when done
loadSize int // desired minimum size in MB of string data for each generated trace
spanDuration time.Duration // duration of generated spans
loadSize int // desired minimum size in MB of string data for each generated trace
spanDuration time.Duration // duration of generated spans
logger *zap.Logger
}

Expand All @@ -45,15 +45,15 @@ func (w worker) simulateTraces(telemetryAttributes []attribute.KeyValue) {
var i int

for w.running.Load() {
spanStart := time.Now()
spanEnd := spanStart.Add(w.spanDuration)
spanStart := time.Now()
spanEnd := spanStart.Add(w.spanDuration)

ctx, sp := tracer.Start(context.Background(), "lets-go", trace.WithAttributes(
ctx, sp := tracer.Start(context.Background(), "lets-go", trace.WithAttributes(
semconv.NetPeerIPKey.String(fakeIP),
semconv.PeerServiceKey.String("telemetrygen-server"),
),
trace.WithSpanKind(trace.SpanKindClient),
trace.WithTimestamp(spanStart),
trace.WithTimestamp(spanStart),
)
sp.SetAttributes(telemetryAttributes...)
for j := 0; j < w.loadSize; j++ {
Expand All @@ -75,7 +75,7 @@ func (w worker) simulateTraces(telemetryAttributes []attribute.KeyValue) {
semconv.PeerServiceKey.String("telemetrygen-client"),
),
trace.WithSpanKind(trace.SpanKindServer),
trace.WithTimestamp(spanStart),
trace.WithTimestamp(spanStart),
)
child.SetAttributes(telemetryAttributes...)

Expand Down
Loading