Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

OTLP forward: missing-headers warning restates the whole forward

Claude58efd7051030
diff --git a/cli/beacon/cmd/endpoint_install.go b/cli/beacon/cmd/endpoint_install.go
index 01c04344..8579fe2a 100644
--- a/cli/beacon/cmd/endpoint_install.go
+++ b/cli/beacon/cmd/endpoint_install.go
@@ -154,11 +154,37 @@ func warnMissingOTLPForwardHeaders(out io.Writer) {
return
}
if forward := cfg.Destinations.OTLPForward; forward.Enabled && forward.HeadersMissing {
- fmt.Fprintf(out, "Warning: the OTLP forward to %s names headers (%s) whose values are missing (%s was removed); it will send without them until you run this again with --otlp-forward-header\n",
- forward.Endpoint, strings.Join(forward.HeaderNames, ", "), endpointconfig.OTLPForwardSecretsPath(endpointUserMode()))
+ fmt.Fprintf(out, "Warning: the OTLP forward to %s names headers (%s) whose values are missing (%s was removed), so it sends without them. Set the forward again with all its flags:\n %s\n",
+ forward.Endpoint, strings.Join(forward.HeaderNames, ", "), endpointconfig.OTLPForwardSecretsPath(endpointUserMode()), otlpForwardFlags(forward))
}
}
+// otlpForwardFlags spells the flags that set forward again as it is configured, with a placeholder
+// for each header value. Passing --otlp-forward-endpoint replaces the whole forward, so every
+// setting is restated, not only the headers.
+func otlpForwardFlags(forward *endpointconfig.OTLPForward) string {
+ flags := []string{"--otlp-forward-endpoint " + shellQuote(forward.Endpoint)}
+ if forward.Protocol != "" && forward.Protocol != endpointconfig.OTLPForwardProtocolGRPC {
+ flags = append(flags, "--otlp-forward-protocol "+forward.Protocol)
+ }
+ if len(forward.Harnesses) > 0 && strings.Join(forward.Harnesses, ",") != strings.Join(endpointconfig.DefaultOTLPForwardHarnesses, ",") {
+ flags = append(flags, "--otlp-forward-harness "+shellQuote(strings.Join(forward.Harnesses, ",")))
+ }
+ if forward.Insecure {
+ flags = append(flags, "--otlp-forward-insecure")
+ }
+ if forward.InsecureSkipVerify {
+ flags = append(flags, "--otlp-forward-insecure-skip-verify")
+ }
+ if forward.CAFile != "" {
+ flags = append(flags, "--otlp-forward-ca-file "+shellQuote(forward.CAFile))
+ }
+ for _, name := range forward.HeaderNames {
+ flags = append(flags, "--otlp-forward-header "+shellQuote(name+"=<value>"))
+ }
+ return strings.Join(flags, " ")
+}
+
// errSetupCancelled replaces the wizard's own "onboarding cancelled", which read as a failure
// and left the person to guess what state the machine was in. The wizard runs before anything is
// written, so the answer is always the same: nothing changed, and here is how to start again.
diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.go
index 1963ca93..cf98f3bc 100644
--- a/cli/beacon/cmd/endpoint_test.go
+++ b/cli/beacon/cmd/endpoint_test.go
@@ -490,6 +490,26 @@ func TestOTLPForwardHarnesses(t *testing.T) {
}
}
+// The missing-headers warning prints the whole forward: --otlp-forward-endpoint replaces it, so a
+// command that restated only the headers would drop the protocol and the rest.
+func TestOTLPForwardFlagsRestateTheWholeForward(t *testing.T) {
+ got := otlpForwardFlags(&endpointconfig.OTLPForward{
+ Endpoint: "https://otel.backend.example",
+ Protocol: endpointconfig.OTLPForwardProtocolHTTP,
+ Harnesses: []string{"claude_code"},
+ CAFile: "/etc/ssl/backend ca.pem",
+ HeaderNames: []string{"authorization", "x-org"},
+ })
+ want := "--otlp-forward-endpoint https://otel.backend.example --otlp-forward-protocol http/protobuf --otlp-forward-harness claude_code" +
+ " --otlp-forward-ca-file '/etc/ssl/backend ca.pem' --otlp-forward-header 'authorization=<value>' --otlp-forward-header 'x-org=<value>'"
+ if got != want {
+ t.Fatalf("otlpForwardFlags =\n %s\nwant\n %s", got, want)
+ }
+ if got := otlpForwardFlags(&endpointconfig.OTLPForward{Endpoint: "otel.example:4317", Protocol: "grpc", Harnesses: endpointconfig.DefaultOTLPForwardHarnesses, Insecure: true}); got != "--otlp-forward-endpoint otel.example:4317 --otlp-forward-insecure" {
+ t.Fatalf("defaults not left out: %s", got)
+ }
+}
+
func TestRepairCollectorServiceRollsBackWhenReadinessFails(t *testing.T) {
oldOpts := endpointOpts
oldLoadConfig := repairLoadEndpointConfig