Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 27 additions & 0 deletions .chloggen/telemetrygen_allow_failed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: telemetrygen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add --allow-export-failures flag to telemetrygen to continue running when export operations fail (instead of terminating)

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [42135]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
7 changes: 7 additions & 0 deletions cmd/telemetrygen/internal/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Config struct {

// OTLP mTLS configuration
ClientAuth ClientAuth

// Export behavior configuration
AllowExportFailures bool
}

type ClientAuth struct {
Expand Down Expand Up @@ -195,6 +198,9 @@ func (c *Config) CommonFlags(fs *pflag.FlagSet) {
fs.BoolVar(&c.ClientAuth.Enabled, "mtls", c.ClientAuth.Enabled, "Whether to require client authentication for mTLS")
fs.StringVar(&c.ClientAuth.ClientCertFile, "client-cert", c.ClientAuth.ClientCertFile, "Client certificate file")
fs.StringVar(&c.ClientAuth.ClientKeyFile, "client-key", c.ClientAuth.ClientKeyFile, "Client private key file")

// Export behavior configuration
fs.BoolVar(&c.AllowExportFailures, "allow-export-failures", c.AllowExportFailures, "Whether to continue running when export operations fail (instead of terminating)")
}

// SetDefaults is here to mirror the defaults for flags above,
Expand All @@ -218,4 +224,5 @@ func (c *Config) SetDefaults() {
c.ClientAuth.Enabled = false
c.ClientAuth.ClientCertFile = ""
c.ClientAuth.ClientKeyFile = ""
c.AllowExportFailures = false
}
1 change: 1 addition & 0 deletions cmd/telemetrygen/pkg/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func run(c *Config, expF exporterFunc, logger *zap.Logger) error {
index: i,
traceID: c.TraceID,
spanID: c.SpanID,
allowFailures: c.AllowExportFailures,
}
exp, err := expF()
if err != nil {
Expand Down
7 changes: 6 additions & 1 deletion cmd/telemetrygen/pkg/logs/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type worker struct {
index int // worker index
traceID string // traceID string
spanID string // spanID string
allowFailures bool // whether to continue on export failures
}

func (w worker) simulateLogs(res *resource.Resource, exporter sdklog.Exporter, telemetryAttributes []attribute.KeyValue) {
Expand Down Expand Up @@ -80,7 +81,11 @@ func (w worker) simulateLogs(res *resource.Resource, exporter sdklog.Exporter, t
}

if err := exporter.Export(context.Background(), logs); err != nil {
w.logger.Fatal("exporter failed", zap.Error(err))
if w.allowFailures {
w.logger.Error("exporter failed, continuing due to --allow-export-failures", zap.Error(err))
} else {
w.logger.Fatal("exporter failed", zap.Error(err))
}
}

i++
Expand Down
1 change: 1 addition & 0 deletions cmd/telemetrygen/pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func run(c *Config, expF exporterFunc, logger *zap.Logger) error {
logger: logger.With(zap.Int("worker", i)),
index: i,
clock: &realClock{},
allowFailures: c.AllowExportFailures,
}
exp, err := expF()
if err != nil {
Expand Down
7 changes: 6 additions & 1 deletion cmd/telemetrygen/pkg/metrics/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type worker struct {
logger *zap.Logger // logger
index int // worker index
clock Clock // clock
allowFailures bool // whether to continue on export failures
}

// We use a 15-element bounds slice for histograms below, so there must be 16 buckets here.
Expand Down Expand Up @@ -173,7 +174,11 @@ func (w worker) simulateMetrics(res *resource.Resource, exporter sdkmetric.Expor
}

if err := exporter.Export(context.Background(), &rm); err != nil {
w.logger.Fatal("exporter failed", zap.Error(err))
if w.allowFailures {
w.logger.Error("exporter failed, continuing due to --allow-export-failures", zap.Error(err))
} else {
w.logger.Fatal("exporter failed", zap.Error(err))
}
}

i++
Expand Down
1 change: 1 addition & 0 deletions cmd/telemetrygen/pkg/traces/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func run(c *Config, logger *zap.Logger) error {
logger: logger.With(zap.Int("worker", i)),
loadSize: c.LoadSize,
spanDuration: c.SpanDuration,
allowFailures: c.AllowExportFailures,
}

go w.simulateTraces(telemetryAttributes)
Expand Down
1 change: 1 addition & 0 deletions cmd/telemetrygen/pkg/traces/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type worker struct {
loadSize int // desired minimum size in MB of string data for each generated trace
spanDuration time.Duration // duration of generated spans
logger *zap.Logger
allowFailures bool // whether to continue on export failures
}

const (
Expand Down
Loading