Skip to content

gcp-resources: detect Cloud Run functions, worker pools, and instances - #3233

Open
DylanRussell wants to merge 2 commits into
open-telemetry:mainfrom
DylanRussell:fix-gcp-resources-cloud-run
Open

DylanRussell wants to merge 2 commits into
open-telemetry:mainfrom
DylanRussell:fix-gcp-resources-cloud-run

Conversation

@DylanRussell

@DylanRussell DylanRussell commented Nov 19, 2026 •

Copy link
Copy Markdown

Description:

Follow-up to #3229 (matching open-telemetry/opentelemetry-python-contrib#5363 and open-telemetry/opentelemetry-go-contrib#10350). cc @psx95

  • Check K_CONFIGURATION before FUNCTION_TARGET: Cloud Run functions (gcloud run deploy --function) and Cloud Functions (2nd gen) run as Cloud Run services and set both K_CONFIGURATION and FUNCTION_TARGET, whereas Cloud Functions (1st gen) only sets FUNCTION_TARGET.
    • Behavior change: Cloud Functions (2nd gen) now report cloud.platform=gcp_cloud_run and cloud.resource_id=//run.googleapis.com/projects/{project}/locations/{region}/services/{name} instead of gcp_cloud_functions. Cloud Functions (1st gen) is unchanged.
  • Add Cloud Run worker pool detection: detects CLOUD_RUN_WORKER_POOL (CLOUD_RUN_REVISION, instance/id, instance/region) per the worker pools contract as gcp_cloud_run with cloud.resource_id=//run.googleapis.com/projects/{project}/locations/{region}/workerPools/{name}.
  • Add Cloud Run instance detection: detects CLOUD_RUN_INSTANCE (docs) as gcp_cloud_run with cloud.resource_id=//run.googleapis.com/projects/{project}/locations/{region}/instances/{name}.

Testing:

  • Ran ./gradlew :gcp-resources:spotlessCheck :gcp-resources:check --rerun-tasks --console=plain (74 tests passed, 0 failures; Spotless, ErrorProne, and NullAway checks passed).
  • Added unit tests in GcpPlatformDetectorTest and GCPResourceProviderTest for Cloud Run functions precedence, worker pools, and instances.

Documentation:

Existing gcp-resources/README.md table already covers GCR (gcp_cloud_run and cloud.resource_id).

@DylanRussell
DylanRussell requested a review from a team as a code owner November 19, 2026 20:01
Copilot AI balanced review requested due to automatic review settings November 19, 2026 20:01
@github-actions
github-actions Bot requested review from jsuereth and psx95 November 19, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the Cloud Run detection and worker pool support changes.

No open issues 🎉

What changed in this PR

Updates gcp-resources platform detection and resource attributes, building on #3229 to correctly identify Cloud Run functions and support Cloud Run worker pools.

Changes:

  • Classifies Cloud Run functions, including Cloud Functions 2nd gen, as Cloud Run by prioritizing K_CONFIGURATION; first-generation detection remains unchanged.
  • Adds worker pool detection, metadata extraction, and cloud.resource_id values using the workerPools resource path.
  • Extends tests for classification precedence, worker pool attribute mapping, optional revision, and incomplete resource IDs.
File Description
gcp-resources/​src/​test/​java/​io/​opentelemetry/​contrib/​gcp/​resource/​GCPResourceProviderTest.java Tests worker pool attribute mapping and resource-ID completeness.
gcp-resources/​src/​test/​java/​io/​opentelemetry/​contrib/​gcp/​resource/​GcpPlatformDetectorTest.java Tests function classification precedence and worker pool detection.
gcp-resources/​src/​main/​java/​io/​opentelemetry/​contrib/​gcp/​resource/​GoogleCloudRunWorkerPool.java Extracts worker pool name, revision, instance ID, and region.
gcp-resources/​src/​main/​java/​io/​opentelemetry/​contrib/​gcp/​resource/​GCPResourceProvider.java Maps worker pools to Cloud Run attributes and resource IDs.
gcp-resources/​src/​main/​java/​io/​opentelemetry/​contrib/​gcp/​resource/​GcpPlatformDetector.java Adjusts function classification and registers worker pool detection.

Review effort: Balanced

@DylanRussell DylanRussell changed the title gcp-resources: detect Cloud Run functions as Cloud Run and add worker pool support gcp-resources: detect Cloud Run functions, worker pools, instances, and Vertex AI Agent Engine Nov 19, 2026
@DylanRussell
DylanRussell force-pushed the fix-gcp-resources-cloud-run branch from dac5be5 to cf1beb6 Compare November 19, 2026 21:32
@DylanRussell DylanRussell changed the title gcp-resources: detect Cloud Run functions, worker pools, instances, and Vertex AI Agent Engine gcp-resources: detect Cloud Run functions, worker pools, and instances Nov 19, 2026

This branch has not been deployed

No deployments
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