Skip to content

Add Google Cloud Run worker identity/deployment helper - #855

Draft
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id
Draft

Add Google Cloud Run worker identity/deployment helper#855
seanbollin wants to merge 1 commit into
mainfrom
cloud-run-worker-id

Conversation

@seanbollin

Copy link
Copy Markdown
Contributor

What & why

The .NET SDK already ships an AWS Lambda extension (Temporalio.Extensions.Aws.Lambda) that sets the worker "ID" for Lambda, and a committed Temporalio.Extensions.Gcp.CloudRun.OpenTelemetry package for Cloud Run observability. This adds the worker-identity / deployment-version piece for Google Cloud Run, as the base Temporalio.Extensions.Gcp.CloudRun package, covering both Cloud Run worker pools and services.

Cloud Run runs a long-lived container, so — unlike Lambda's per-invocation handler — there is nothing to wrap. This is a small metadata helper that follows the same idiom as the sibling .OpenTelemetry package (GoogleCloudRun-prefixed types, ApplyGoogleCloudRun… extension methods, WARNING: … experimental remark).

What it does

GoogleCloudRunMetadata.FetchAsync(), called once at startup:

  • resolves the deployment Name from CLOUD_RUN_WORKER_POOL (worker pools) → K_SERVICE (services), and the Revision from CLOUD_RUN_REVISIONK_REVISION, and
  • makes a single HTTP GET to the instance metadata server (http://metadata.google.internal/computeMetadata/v1/instance/id, header Metadata-Flavor: Google) for the unique instance id (available on both).

Extension methods apply it to your normal, long-lived worker:

  • await connectOptions.ApplyGoogleCloudRunDefaultsAsync() → fetches metadata, sets Identity to {InstanceId}@{Revision} (only if unset), and returns the metadata; and
  • workerOptions.ApplyGoogleCloudRunDefaults(metadata) → sets DeploymentOptions = new WorkerDeploymentOptions(metadata.ToWorkerDeploymentVersion(), useWorkerVersioning: true).

(WorkerIdentity / ToWorkerDeploymentVersion() are also exposed for direct use.)

Notes

  • Draft — opening early for design feedback. Idiom intentionally matches the committed sibling Temporalio.Extensions.Gcp.CloudRun.OpenTelemetry.
  • No new package dependencies (HttpClient is in the BCL).
  • No unit tests yet (kept intentionally minimal for the draft).
  • Follow-up before un-drafting: wire the new package into .github/workflows/nuget-package.yml and the API-docs (src/Temporalio.ApiDoc/…) the way the .OpenTelemetry package is, and add tests under tests/Temporalio.Tests/Extensions/Gcp/CloudRun/.
  • Verified locally: warning-clean dotnet build (TreatWarningsAsErrors + StyleCop + full analyzers), dotnet format --verify-no-changes, and dotnet pack all pass.

🤖 Generated with Claude Code

Adds an experimental Google Cloud Run helper, mirroring the existing AWS
Lambda module's worker-ID behavior. Because Cloud Run runs a long-lived
container (unlike Lambda's per-invocation model), this is a metadata
helper rather than a worker wrapper: it reads the Cloud Run instance
metadata -- the instance id from the metadata server, plus the worker
pool/service name and revision from CLOUD_RUN_WORKER_POOL / CLOUD_RUN_REVISION
(worker pools) or K_SERVICE / K_REVISION (services) -- and derives a worker
identity and a WorkerDeploymentVersion to apply to a normal long-lived
worker. Covers both Cloud Run worker pools and services.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jmaeagle99 jmaeagle99 self-assigned this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants