Add Google Cloud Run worker identity/deployment helper - #855
Draft
seanbollin wants to merge 1 commit into
Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The .NET SDK already ships an AWS Lambda extension (
Temporalio.Extensions.Aws.Lambda) that sets the worker "ID" for Lambda, and a committedTemporalio.Extensions.Gcp.CloudRun.OpenTelemetrypackage for Cloud Run observability. This adds the worker-identity / deployment-version piece for Google Cloud Run, as the baseTemporalio.Extensions.Gcp.CloudRunpackage, 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
.OpenTelemetrypackage (GoogleCloudRun-prefixed types,ApplyGoogleCloudRun…extension methods,WARNING: … experimentalremark).What it does
GoogleCloudRunMetadata.FetchAsync(), called once at startup:CLOUD_RUN_WORKER_POOL(worker pools) →K_SERVICE(services), and the Revision fromCLOUD_RUN_REVISION→K_REVISION, andhttp://metadata.google.internal/computeMetadata/v1/instance/id, headerMetadata-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, setsIdentityto{InstanceId}@{Revision}(only if unset), and returns the metadata; andworkerOptions.ApplyGoogleCloudRunDefaults(metadata)→ setsDeploymentOptions = new WorkerDeploymentOptions(metadata.ToWorkerDeploymentVersion(), useWorkerVersioning: true).(
WorkerIdentity/ToWorkerDeploymentVersion()are also exposed for direct use.)Notes
Temporalio.Extensions.Gcp.CloudRun.OpenTelemetry..github/workflows/nuget-package.ymland the API-docs (src/Temporalio.ApiDoc/…) the way the.OpenTelemetrypackage is, and add tests undertests/Temporalio.Tests/Extensions/Gcp/CloudRun/.dotnet build(TreatWarningsAsErrors + StyleCop + full analyzers),dotnet format --verify-no-changes, anddotnet packall pass.🤖 Generated with Claude Code