{"record":{"id":"18926e508ba87aa7","repo":"pulumi/pulumi","slug":"failed-to-connect-to-otlp-collector-w","errorCode":null,"errorMessage":"failed to connect to OTLP collector: %w","messagePattern":"failed to connect to OTLP collector: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/common/util/otelreceiver/grpc_exporter.go","lineNumber":62,"sourceCode":"\theaders map[string]string\n}\n\nfunc newGRPCExporterWithOptions(opts grpcExporterOptions) (*GRPCExporter, error) {\n\ttarget := strings.TrimPrefix(opts.target, \"grpc://\")\n\ttarget = strings.TrimPrefix(target, \"grpcs://\")\n\n\tvar dialOpts []grpc.DialOption\n\tif opts.tls {\n\t\tdialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{\n\t\t\tMinVersion: tls.VersionTLS12,\n\t\t})))\n\t} else {\n\t\tdialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials()))\n\t}\n\n\tconn, err := grpc.NewClient(target, dialOpts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to connect to OTLP collector: %w\", err)\n\t}\n\n\tvar md metadata.MD\n\tif len(opts.headers) > 0 {\n\t\tmd = metadata.New(opts.headers)\n\t}\n\n\treturn &GRPCExporter{\n\t\tconn:    conn,\n\t\tclient:  coltracepb.NewTraceServiceClient(conn),\n\t\theaders: md,\n\t}, nil\n}\n\nfunc (e *GRPCExporter) ExportSpans(ctx context.Context, spans []*tracepb.ResourceSpans) error {\n\tif len(spans) == 0 {\n\t\treturn nil\n\t}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/common/util/otelreceiver/grpc_exporter.go#L44-L80","documentation":"The gRPC span exporter establishes a client connection to an OTLP collector with grpc.NewClient using the configured target address. If the client cannot be constructed — invalid endpoint syntax, unsupported scheme, or bad dial options — this wrapped error is returned and the receiver fails to start.","triggerScenarios":"otelreceiver.Start is called with a gRPC exporter whose target string is malformed (e.g. 'localhost:xyz', empty, or an unparseable scheme like 'unix://'), or with dial options that grpc.NewClient rejects (invalid TLS credentials configuration).","commonSituations":"Typos in the PULUMI_OTEL_EXPORTER_OTLP_ENDPOINT-style env var; passing a URL ('http://host:4317') where a bare host:port is expected; bad custom endpoint from a self-hosted collector config; DNS/unix socket schemes the grpc resolver cannot handle.","solutions":["Validate the target is a valid host:port or accepted grpc target (strip http:// or https:// scheme prefixes)","Confirm the collector address and port, e.g. test with `grpcurl -plaintext host:4317`","Check TLS settings: if the endpoint expects TLS, don't pass insecure credentials, and vice versa","Log the wrapped inner error (%w) for the precise grpc parser message"],"exampleFix":"// before\nexporter, err := newGRPCExporter(ctx, \"http://localhost:4317\", opts)\n// after\nexporter, err := newGRPCExporter(ctx, \"localhost:4317\", opts)","handlingStrategy":"validation","validationCode":"// validate a gRPC target before handing it to the exporter\nu, err := url.Parse(endpoint)\nvalid := err == nil && (u.Scheme == \"\" && net.ParseIP(u.Hostname()) != nil ||\n    u.Scheme == \"dns\" || u.Scheme == \"passthrough\") && u.Port() != \"\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip http:// or https:// scheme prefixes from endpoints before passing to gRPC exporters","Use bare host:port targets (e.g. localhost:4317) for OTLP gRPC","Test the endpoint with grpcurl before wiring it up"],"tags":["network","grpc","opentelemetry","configuration"],"backgroundTag":"grpc-dial-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}