{"record":{"id":"a8bbb72516adeec4","repo":"vxcontrol/pentagi","slug":"failed-to-create-log-exporter-w","errorCode":null,"errorMessage":"failed to create log exporter: %w","messagePattern":"failed to create log exporter: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/observability/otelclient.go","lineNumber":122,"sourceCode":"\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()\n\t\treturn nil, fmt.Errorf(\"failed to create tracer exporter: %w\", err)\n\t}\n\n\tlogProvider := sdklog.NewLoggerProvider(\n\t\tsdklog.WithProcessor(sdklog.NewBatchProcessor(\n\t\t\tlogExporter,\n\t\t\tsdklog.WithExportInterval(DefaultLogInterval),\n\t\t\tsdklog.WithExportTimeout(DefaultLogTimeout),\n\t\t)),","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/observability/otelclient.go#L104-L140","documentation":"Construction of the OTLP gRPC log exporter (otlploggrpc.New) failed during NewTelemetryClient. Exporter creation is the only error path after the connection is made, and on failure the shared conn is closed for a complete teardown before returning this wrapped error.","triggerScenarios":"otlploggrpc.New returning an error: usually invalid TLS/credentials options or internal SDK setup failure; with the insecure pre-wired conn this is rare and typically indicates an SDK/version incompatibility.","commonSituations":"Version mismatch between otel SDK and otlploggrpc packages (go.mod drift); corrupted dependency install; future option changes like switching to TLS credentials with a bad cert.","solutions":["Run `go mod tidy` / `go mod download` to align otel module versions","Check the wrapped error text for the true cause","If adding TLS, verify certificate files exist and are valid","Rebuild the binary after dependency changes"],"exampleFix":"// before\nlogExporter, err := otlploggrpc.New(ctx, otlploggrpc.WithGRPCConn(conn))\nif err != nil { return nil, err }\n// after\nlogExporter, err := otlploggrpc.New(ctx, otlploggrpc.WithGRPCConn(conn))\nif err != nil {\n    _ = conn.Close() // already done upstream\n    return nil, fmt.Errorf(\"failed to create log exporter: %w\", err)\n}","handlingStrategy":"fallback","validationCode":"// ensure go.mod has a single coherent set of go.opentelemetry.io/otel* versions\n// run: go mod tidy && go build ./...","typeGuard":null,"tryCatchPattern":"client, err := NewTelemetryClient(ctx, cfg)\nif err != nil {\n    log.Warnf(\"telemetry disabled due to init failure: %v\", err)\n    client = nil // app continues without telemetry\n}","preventionTips":["Keep otel SDK/exporter module versions aligned (go mod tidy)","Rebuild after dependency upgrades","Run the otelclient tests (TestNewTelemetryClient_*) in CI","Fail soft: telemetry should not take the app down"],"tags":["opentelemetry","exporter","logs","grpc"],"backgroundTag":"exporter-init-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}