{"record":{"id":"350ef83a6d41f468","repo":"vxcontrol/pentagi","slug":"failed-to-create-telemetry-connection-w","errorCode":null,"errorMessage":"failed to create telemetry connection: %w","messagePattern":"failed to create telemetry connection: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/observability/otelclient.go","lineNumber":113,"sourceCode":"\treturn errors.Join(errs...)\n}\n\nfunc NewTelemetryClient(ctx context.Context, cfg *config.Config) (TelemetryClient, error) {\n\tif cfg.TelemetryEndpoint == \"\" {\n\t\treturn nil, fmt.Errorf(\"telemetry endpoint is not set: %w\", ErrNotConfigured)\n\t}\n\n\t// grpc.NewClient is non-blocking: it never dials during startup, so a\n\t// set-but-unreachable collector can't stall main(), and the connection is\n\t// established (and re-established) lazily in the background — a collector that\n\t// comes up after the app does connects on its own, without a restart.\n\tconn, err := grpc.NewClient(\n\t\tcfg.TelemetryEndpoint,\n\t\tgrpc.WithTransportCredentials(insecure.NewCredentials()),\n\t\tgrpc.WithDefaultCallOptions(grpc.WaitForReady(true)),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create telemetry connection: %w\", err)\n\t}\n\n\t// Build all three exporters before creating any provider. Exporter creation\n\t// is the only remaining error path, and at that point no batch/reader\n\t// goroutine has started yet, so closing the connection is a complete teardown.\n\tlogExporter, err := otlploggrpc.New(ctx, otlploggrpc.WithGRPCConn(conn))\n\tif err != nil {\n\t\t_ = conn.Close()\n\t\treturn nil, fmt.Errorf(\"failed to create log exporter: %w\", err)\n\t}\n\tmetricExporter, err := otlpmetricgrpc.New(ctx, otlpmetricgrpc.WithGRPCConn(conn))\n\tif err != nil {\n\t\t_ = conn.Close()\n\t\treturn nil, fmt.Errorf(\"failed to create metric exporter: %w\", err)\n\t}\n\tspanExporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithGRPCConn(conn))\n\tif err != nil {\n\t\t_ = conn.Close()","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/observability/otelclient.go#L95-L131","documentation":"NewTelemetryClient failed at the grpc.NewClient step that creates the shared non-blocking gRPC connection to the OTLP collector. Because grpc.NewClient is lazy, failure here almost always means an invalid target string (bad address/URL syntax), not an unreachable server.","triggerScenarios":"cfg.TelemetryEndpoint contains a malformed target (e.g. includes a scheme like http://, spaces, or an unparseable host:port), or gRPC client construction fails for a credentials/options reason.","commonSituations":"Users pasting a full URL (https://collector:4317) instead of host:port; trailing slashes or protocol prefixes in the telemetry endpoint env var.","solutions":["Ensure cfg.TelemetryEndpoint is plain host:port (e.g. 'otel-collector:4317'), no scheme, no path","Check the wrapped error message for target-parse details","Fix the endpoint env var in .env / docker-compose environment and restart","If using DNS, make sure the resolver works inside the container network"],"exampleFix":"// before\nTELEMETRY_ENDPOINT=https://localhost:4317/v1/metrics\n// after\nTELEMETRY_ENDPOINT=localhost:4317","handlingStrategy":"validation","validationCode":"endpoint := cfg.TelemetryEndpoint\nif endpoint == \"\" || strings.Contains(endpoint, \"://\") || strings.Contains(endpoint, \"/\") {\n    return fmt.Errorf(\"invalid telemetry endpoint %q: want host:port\", endpoint)\n}","typeGuard":null,"tryCatchPattern":"client, err := NewTelemetryClient(ctx, cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to create telemetry connection\") {\n        return fmt.Errorf(\"check TELEMETRY_ENDPOINT format (host:port, no scheme): %w\", err)\n    }\n    return err\n}","preventionTips":["Use plain host:port for the endpoint, never a URL","Validate endpoint format in pkg/config with a regex","Test the endpoint with a simple gRPC client before rollout","Strip schemes/paths in installer wizard input"],"tags":["grpc","configuration","opentelemetry"],"backgroundTag":"invalid-endpoint-target","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}