{"record":{"id":"2f6d257ef6dcffbd","repo":"googleapis/mcp-toolbox","slug":"s-s","errorCode":null,"errorMessage":"%s: %s","messagePattern":"%s: %s","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/telemetry/telemetry.go","lineNumber":203,"sourceCode":"\t\t\tmetric.Instrument{Name: name},\n\t\t\tmetric.Stream{\n\t\t\t\tAggregation: metric.AggregationExplicitBucketHistogram{\n\t\t\t\t\tBoundaries: durationBuckets,\n\t\t\t\t},\n\t\t\t},\n\t\t))\n\t}\n\tmetricOpts = append(metricOpts, metric.WithView(views...))\n\n\tmeterProvider := metric.NewMeterProvider(metricOpts...)\n\treturn meterProvider, nil\n}\n\nfunc wrapGCPProjectHint(err error) error {\n\tmessage := err.Error()\n\tif strings.Contains(message, \"no project found with application default credentials\") {\n\t\tprojectHint := \"please ensure that `--telemetry-gcp-project` flag or `GOOGLE_CLOUD_PROJECT` env var is set, and `GOOGLE_APPLICATION_CREDENTIALS` points to valid ADC credentials\"\n\t\treturn fmt.Errorf(\"%s: %s\", projectHint, message)\n\t}\n\treturn err\n}\n","sourceCodeStart":185,"sourceCodeEnd":207,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/telemetry/telemetry.go#L185-L207","documentation":"wrapGCPProjectHint decorates errors raised while creating the GCP cloud trace/meter exporters. When the underlying error indicates Application Default Credentials could not detect a project, the error is prefixed with a hint to set --telemetry-gcp-project or GOOGLE_CLOUD_PROJECT and point GOOGLE_APPLICATION_CREDENTIALS at valid ADC credentials.","triggerScenarios":"Starting the server with GCP telemetry (newTracerProvider/newMeterProvider using cloud trace or monitoring exporters) when ADC finds no project: no --telemetry-gcp-project flag, no GOOGLE_CLOUD_PROJECT env var, and credentials without a project_id.","commonSituations":"Local/on-prem deployments with GCP telemetry configured; service-account key files missing project_id; GOOGLE_APPLICATION_CREDENTIALS lost after a container rebuild; workload identity not attached.","solutions":["Set the --telemetry-gcp-project flag or the GOOGLE_CLOUD_PROJECT env var","Point GOOGLE_APPLICATION_CREDENTIALS at a valid ADC credentials file containing project_id","Run `gcloud auth application-default login` to establish ADC locally","If GCP telemetry is unintended, switch the --telemetry output to a non-GCP exporter"],"exampleFix":"// before\nexport GOOGLE_APPLICATION_CREDENTIALS=/path/key.json\n// after\nexport GOOGLE_APPLICATION_CREDENTIALS=/path/key.json\nexport GOOGLE_CLOUD_PROJECT=my-gcp-project","handlingStrategy":"validation","validationCode":"if os.Getenv(\"GOOGLE_CLOUD_PROJECT\") == \"\" && !flagSet(\"telemetry-gcp-project\") &&\n  os.Getenv(\"GOOGLE_APPLICATION_CREDENTIALS\") == \"\" {\n  log.Fatal(\"GCP telemetry requires GOOGLE_CLOUD_PROJECT (or --telemetry-gcp-project) and valid ADC credentials\")\n}","typeGuard":null,"tryCatchPattern":"if err := telemetry.SetupOTel(...); err != nil {\n  if strings.Contains(err.Error(), \"no project found with application default credentials\") {\n    log.Fatalf(\"GCP project hint: %v\", err)\n  }\n  return err\n}","preventionTips":["Always set GOOGLE_CLOUD_PROJECT when using GCP telemetry","Verify ADC credentials contain a project_id claim","Prefer workload identity on GCP over key files"],"tags":["gcp","telemetry","adc","configuration"],"backgroundTag":"missing-gcp-credentials","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}