kubernetes/kops · error
already started
Error message
already started
What it means
The otlptracefile client implements the otlptrace.Client interface; Start initializes the file writer and may only be called once. If Start is invoked while c.writer is already non-nil (a previous Start succeeded), it returns "already started" to prevent re-initializing and clobbering the open trace file.
Source
Thrown at pkg/otel/otlptracefile/client.go:59
var cfg Config
for _, option := range opts {
option(&cfg)
}
c := &client{
cfg: cfg,
}
return c
}
// Start implements otlptrace.Client.
func (c *client) Start(ctx context.Context) error {
c.writerMutex.Lock()
defer c.writerMutex.Unlock()
if c.writer != nil {
return fmt.Errorf("already started")
}
w, err := newWriter(c.cfg)
if err != nil {
return err
}
c.writer = w
return nil
}
// Stop implements otlptrace.Client.
func (c *client) Stop(ctx context.Context) error {
c.writerMutex.Lock()
defer c.writerMutex.Unlock()
if c.writer != nil {
err := c.writer.Close()View on GitHub (pinned to 4c8573c808)
Solutions
- Call Start only once per client instance; guard with a sync.Once or a started flag.
- Call Shutdown/Stop before invoking Start again, or create a fresh client instance.
- Share one tracer provider instead of creating multiple ones around the same client.
Example fix
// before
client.Start(ctx)
client.Start(ctx) // panics path: already started
// after
var once sync.Once
once.Do(func() { client.Start(ctx) }) Defensive patterns
Strategy: try-catch
Validate before calling
var started bool
func startOnce(c otlptrace.Client, ctx context.Context) error {
if started { return nil }
started = true
return c.Start(ctx)
} Try / catch
if err := client.Start(ctx); err != nil {
if strings.Contains(err.Error(), "already started") {
return nil // idempotent start
}
return err
} Prevention
- Wrap exporter Start in sync.Once
- Keep exporter lifecycle in one bootstrap location
- Call Shutdown before any restart of the exporter
When it happens
Trigger: Calling client.Start(ctx) twice without an intervening Shutdown; registering the same otlptracefile client with two tracers that both call Start.
Common situations: Application bootstrap code that starts the exporter in two places (e.g. both main and an init path); hot-reload logic re-calling Start on config change without shutting down first.
Related errors
- already closed
- incorrect syntax for lifecyle-overrides, correct syntax is T
- unknown lifecycle %q, available lifecycle: %s
- duplicate scope: %q
- shutdown already in progress
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/12e16475b1c773f6.
Report an issue: GitHub.