{"record":{"id":"da43aacb58a0a37a","repo":"grpc/grpc-go","slug":"failed-to-create-cloudloggingexporter-v","errorCode":null,"errorMessage":"failed to create cloudLoggingExporter: %v","messagePattern":"failed to create cloudLoggingExporter: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gcp/observability/exporting.go","lineNumber":67,"sourceCode":"// In future, we might expose this to allow users provide custom exporters. But\n// now, it exists for testing purposes.\ntype loggingExporter interface {\n\t// EmitGrpcLogRecord writes a gRPC LogRecord to cache without blocking.\n\tEmitGcpLoggingEntry(entry gcplogging.Entry)\n\t// Close flushes all pending data and closes the exporter.\n\tClose() error\n}\n\ntype cloudLoggingExporter struct {\n\tprojectID string\n\tclient    *gcplogging.Client\n\tlogger    *gcplogging.Logger\n}\n\nfunc newCloudLoggingExporter(ctx context.Context, config *config) (loggingExporter, error) {\n\tc, err := gcplogging.NewClient(ctx, fmt.Sprintf(\"projects/%v\", config.ProjectID), cOptsDisableLogTrace...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create cloudLoggingExporter: %v\", err)\n\t}\n\tdefer logger.Infof(\"Successfully created cloudLoggingExporter\")\n\tif len(config.Labels) != 0 {\n\t\tlogger.Infof(\"Adding labels: %+v\", config.Labels)\n\t}\n\treturn &cloudLoggingExporter{\n\t\tprojectID: config.ProjectID,\n\t\tclient:    c,\n\t\tlogger:    c.Logger(\"microservices.googleapis.com/observability/grpc\", gcplogging.CommonLabels(config.Labels), gcplogging.BufferedByteLimit(1024*1024*50), gcplogging.DelayThreshold(time.Second*10)),\n\t}, nil\n}\n\nfunc (cle *cloudLoggingExporter) EmitGcpLoggingEntry(entry gcplogging.Entry) {\n\tcle.logger.Log(entry)\n\tif logger.V(2) {\n\t\tlogger.Infof(\"Uploading event to CloudLogging: %+v\", entry)\n\t}\n}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/gcp/observability/exporting.go#L49-L85","documentation":"newCloudLoggingExporter calls cloud.google.com/go/logging.NewClient(ctx, \"projects/<ProjectID>\", ...) to create the underlying Cloud Logging client; if that returns an error (auth, dial, bad project id, option misconfiguration) the exporter construction fails and the error is wrapped as \"failed to create cloudLoggingExporter: %v\".","triggerScenarios":"Missing or invalid Application Default Credentials; GOOGLE_CLOUD_PROJECT / project_id not a real GCP project; network egress to logging.googleapis.com blocked; passing cOptsDisableLogTrace options that conflict with the environment.","commonSituations":"Workload has ADC scoped without https://www.googleapis.com/auth/logging.write; running in an air-gapped or network-restricted environment; project id typo after fixing 217; expired service-account token.","solutions":["Verify ADC: `gcloud auth application-default print-access-token` succeeds and has logging.write scope.","Confirm the project id is real and that the SA has Roles/Logging Writer (or equivalent).","Check network egress to logging.googleapis.com:443 is allowed (proxy, firewall, NAT).","Inspect the wrapped %v which usually says 'google: could not find default credentials' or a dial error."],"exampleFix":"// before\n// running with no ADC and GOOGLE_CLOUD_PROJECT set to a fake id\n\n// after\nexport GOOGLE_CLOUD_PROJECT=real-project\nexport GOOGLE_APPLICATION_CREDENTIALS=/svc/sa.json\n# `gcloud auth application-default login` for local dev","handlingStrategy":"try-catch","validationCode":"func canCreateLoggingClient(ctx context.Context, project string) error {\n    c, err := gcplogging.NewClient(ctx, \"projects/\"+project)\n    if err != nil { return err }\n    return c.Close()\n}","typeGuard":null,"tryCatchPattern":"le, err := newCloudLoggingExporter(ctx, cfg)\nif err != nil { return fmt.Errorf(\"cloud logging exporter: %w\", err) }\ndefer le.Close()","preventionTips":["Verify ADC and Roles/Logging Writer before Start: `gcloud auth application-default print-access-token`.","Confirm egress to logging.googleapis.com:443 is permitted.","Use a real, accessible project id (not the literal 'projects/<id>' with empty id)."],"tags":["grpc","observability","cloud-logging","auth","gcp","network"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}