grpc/grpc-go · error

unable to create CloudLogging exporter

Error message

unable to create CloudLogging exporter: %v

What it means

startLogging called newLoggingExporter (an alias for newCloudLoggingExporter) and it failed; this is the outer wrapper at logging.go:490 returned to observability.Start. The inner %v is the error from 250. Because Start fails, no client/server logging filters get registered.

Solutions

  1. Read the inner %v (same diagnosis as error 250): fix ADC, project id, network, API enablement.
  2. Ensure GOOGLE_APPLICATION_CREDENTIALS or ADC is set before the process starts.
  3. Validate that Cloud Logging API is enabled on config.ProjectID.
  4. If logging is non-essential, drop cloud_logging from the config so Start does not try to build the exporter.
  5. Retry Start after fixing credentials (Start is meant to be called once, so a fresh process is cleanest).

Example fix

// before
{"project_id":"","cloud_logging":{}}

// after
{"project_id":"my-proj","cloud_logging":{}}
# plus
export GOOGLE_APPLICATION_CREDENTIALS=/etc/sa.json
Defensive patterns

Strategy: try-catch

Validate before calling

// Same pre-flight as error 250: ensure gcplogging.NewClient works before Start.
if _, err := gcplogging.NewClient(ctx, "projects/"+projectID); err != nil {
    return fmt.Errorf("Cloud Logging unreachable, will not call Start: %w", err)
}

Try / catch

if err := observability.Start(ctx); err != nil {
    if strings.Contains(err.Error(), "unable to create CloudLogging exporter") {
        log.Fatalf("Cloud Logging exporter creation failed; verify ADC, project_id, network, API: %v", err)
    }
    return err
}

Prevention

When it happens

Trigger: observability.Start with a cloud_logging block in the config but ADC missing/invalid, project id bad, network to logging.googleapis.com blocked, or the Cloud Logging API disabled. Same root causes as error 250; this is the Start-level surface.

Common situations: Same as 250 in production deployments; surfaces when callers log only the Start error and not the inner exporter error. Often seen on first deploy of the observability plugin.

Related errors


AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11). Data as JSON: /api/errors/ddc907b094e855c9. Report an issue: GitHub.

Appendix: source

Thrown at gcp/observability/logging.go:490

		eventConfigs = append(eventConfigs, eventConfig)
	}
	serverSideLogger := &binaryLogger{
		EventConfigs: eventConfigs,
		exporter:     exporter,
		projectID:    config.ProjectID,
		clientSide:   false,
	}
	internal.AddGlobalServerOptions.(func(opt ...grpc.ServerOption))(internal.BinaryLogger.(func(bl iblog.Logger) grpc.ServerOption)(serverSideLogger))
}

func startLogging(ctx context.Context, config *config) error {
	if config == nil || config.CloudLogging == nil {
		return nil
	}
	var err error
	lExporter, err = newLoggingExporter(ctx, config)
	if err != nil {
		return fmt.Errorf("unable to create CloudLogging exporter: %v", err)
	}

	registerClientRPCEvents(config, lExporter)
	registerServerRPCEvents(config, lExporter)
	return nil
}

func stopLogging() {
	internal.ClearGlobalDialOptions()
	internal.ClearGlobalServerOptions()
	if lExporter != nil {
		// This Close() call handles the flushing of the logging buffer.
		lExporter.Close()
	}
}

View on GitHub (pinned to 0c51461d27)