{"record":{"id":"0be5acf756aa0c20","repo":"grpc/grpc-go","slug":"no-observabilityconfig-found","errorCode":null,"errorMessage":"no ObservabilityConfig found","messagePattern":"no ObservabilityConfig found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gcp/observability/observability.go","lineNumber":54,"sourceCode":"\n// Start is the opt-in API for gRPC Observability plugin. This function should\n// be invoked in the main function, and before creating any gRPC clients or\n// servers, otherwise, they might not be instrumented. At high-level, this\n// module does the following:\n//\n//   - it loads observability config from environment;\n//   - it registers default exporters if not disabled by the config;\n//   - it sets up telemetry collectors (binary logging sink or StatsHandlers).\n//\n// Note: this method should only be invoked once.\n// Note: handle the error\nfunc Start(ctx context.Context) error {\n\tconfig, err := parseObservabilityConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif config == nil {\n\t\treturn fmt.Errorf(\"no ObservabilityConfig found\")\n\t}\n\n\t// Set the project ID if it isn't configured manually.\n\tif err = ensureProjectIDInObservabilityConfig(ctx, config); err != nil {\n\t\treturn err\n\t}\n\n\t// Cleanup any created resources this function created in case this function\n\t// errors.\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tEnd()\n\t\t}\n\t}()\n\n\t// Enabling tracing and metrics via OpenCensus\n\tif err = startOpenCensus(config); err != nil {\n\t\treturn fmt.Errorf(\"failed to instrument OpenCensus: %v\", err)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/gcp/observability/observability.go#L36-L72","documentation":"observability.Start found no config: neither GRPC_GCP_OBSERVABILITY_CONFIG nor GRPC_GCP_OBSERVABILITY_CONFIG_FILE was set (or both empty), so parseObservabilityConfig returned nil and Start refuses to continue. This is a usage error — Start is opt-in and requires one of the env vars.","triggerScenarios":"Calling observability.Start(ctx) in a process where both env vars are unset. Emitted at observability.go:54.","commonSituations":"Forgetting to set the env var in the deployment manifest; setting it under a slightly different name (e.g. GRPC_OBSERVABILITY_CONFIG); env var set in a parent shell but not exported into the systemd unit / container; intent was to disable observability, in which case Start should not be called.","solutions":["Set GRPC_GCP_OBSERVABILITY_CONFIG to a JSON config string or GRPC_GCP_OBSERVABILITY_CONFIG_FILE to a file path before calling Start.","If you did not intend to use observability, remove the Start call entirely.","If using a scheduler, ensure the env var is in the container spec and is exported.","Print os.Environ() in startup logs to confirm which grpc_* vars are visible to the process."],"exampleFix":"// before\nobservability.Start(ctx)\n\n// after\nexport GRPC_GCP_OBSERVABILITY_CONFIG='{\"project_id\":\"my-proj\",\"cloud_logging\":{\"client_rpc_events\":[{\"methods\":[\"*\"]}]}}'\nobservability.Start(ctx)","handlingStrategy":"validation","validationCode":"if os.Getenv(\"GRPC_GCP_OBSERVABILITY_CONFIG\") == \"\" && os.Getenv(\"GRPC_GCP_OBSERVABILITY_CONFIG_FILE\") == \"\" {\n    return errors.New(\"set GRPC_GCP_OBSERVABILITY_CONFIG or GRPC_GCP_OBSERVABILITY_CONFIG_FILE, or remove the observability.Start call\")\n}","typeGuard":null,"tryCatchPattern":"if err := observability.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"no ObservabilityConfig found\") {\n        // either set the env or remove the Start call\n        return fmt.Errorf(\"observability opted-in but no config env var set: %w\", err)\n    }\n    return err\n}","preventionTips":["Decide explicitly: either wire the config env var or don't call Start.","Add the env var to your deployment manifest template.","In tests, set the env var in TestMain or skip the Start call."],"tags":["observability","config","env","startup"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}