For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/serverless/google_cloud_run/functions.md. A documentation index is available at /llms.txt.

Instrumenting Cloud Run Functions

Looking for 1st gen Cloud Run functions? If you're using Cloud Run functions (1st gen), previously known as Cloud Functions (1st gen), see Instrumenting 1st Gen Cloud Run Functions.

Set up with agentic onboarding

This feature is not supported for your selected Datadog site ().

Use agentic onboarding to set up monitoring for your Cloud Run functions with AI assistance. Agentic onboarding detects your project’s frameworks, applies the required configuration in place, and verifies that data is flowing. Two complementary paths use the same Datadog account:

  • Pup CLI: Run pup setup from your terminal. It doesn’t need your own coding assistant or AI model, so setup doesn’t use your model tokens.
  • MCP server: Set up from your IDE through a coding assistant such as Claude Code or Cursor.

Run pup setup in your project directory (requires Node.js 22+). It links your Datadog account, then instruments your Cloud Run function:

npx @datadog/pup setup --product serverless --serverless-compute-type=gcp-cloud-run-functions

Omit --product to run interactively, or add --site to target your Datadog site.

Use the Datadog MCP server’s serverless_onboarding tool to set up monitoring for your Cloud Run functions with AI assistance. After you connect, try a prompt like:

Help me monitor my GCP Cloud Run functions with Datadog using Terraform.

Manual instrumentation

First, set up the Datadog-Google Cloud Platform integration to collect metrics and logs from Google Cloud services. Remember to add the cloud asset viewer role to your service account and enable the Cloud Asset Inventory API in Google Cloud.

Then, select your runtime below for instructions on how to instrument your application:

Python
Node.js
go
Java
.NET
Ruby

Further reading