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
15 changes: 14 additions & 1 deletion core/cmd/gds-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func run(ctx context.Context, arguments []string, stdout io.Writer, stderr io.Wr
}
service := &controller.Service{
Store: store, Webhook: receiver, Worker: worker, Reconciler: runner, Backup: backups,
Telemetry: telemetryExporter,
Telemetry: telemetryFlusher(telemetryExporter),
WebhookPath: runtime.Config.Controller.WebhookPath,
WebhookPoll: time.Duration(
runtime.Config.Controller.Schedule.WebhookPollMilliseconds,
Expand Down Expand Up @@ -177,6 +177,19 @@ func openState(ctx context.Context, path string) (*state.Store, error) {
}
}

// telemetryFlusher hands the exporter to the service's optional sink slot.
// FromEnvironment yields a typed-nil *Exporter when no endpoint is
// configured, and storing that inside the interface field would defeat the
// service's nil guard: the loop would spawn and Flush would panic on a nil
// receiver — measured live as a crash after the first successful
// reconciliation. Absence must stay an untyped nil.
func telemetryFlusher(exporter *telemetry.Exporter) controller.TelemetryFlusher {
if exporter == nil {
return nil
}
return exporter
}

func startupError(writer io.Writer, phase string, err error) int {
_, _ = fmt.Fprintf(writer, "gds-controller: %s startup failed (%T)\n", phase, err)
return 1
Expand Down
6 changes: 6 additions & 0 deletions core/cmd/gds-controller/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ func TestRunRequiresExplicitPrivateRuntime(t *testing.T) {
t.Fatalf("stderr=%q", stderr.String())
}
}

func TestTelemetryFlusherKeepsAbsentExporterUntyped(t *testing.T) {
if telemetryFlusher(nil) != nil {
t.Fatal("absent telemetry became a typed nil inside the interface")
}
}