Set up OpenTelemetry monitoring for Google Cloud Functions

Dynatrace uses OpenTelemetry to monitor Google Cloud Functions invocations.

For that purpose, Dynatrace provides language-specific packages—such as @dynatrace/opentelemetry-gcf for Node.js, dynatrace-opentelemetry-gcf for Python, and Dynatrace.OpenTelemetry.Instrumentation.GoogleCloudFunctions for .NET—that can be used in combination with default OpenTelemetry SDKs and APIs.

Prerequisites

  • Dynatrace version 1.240+
  • OneAgent version 1.193+ for all OneAgents participating in a trace
  • Go to Settings > Preferences > OneAgent features and activate the Forward Tag 4 trace context extension OneAgent feature.

Installation

Step 1 Select a configuration method

  1. In Dynatrace Hub, select OneAgent.
  2. Select Set up > Google Cloud Functions.
  3. On the Enable Monitoring for Google Cloud Functions page, under How will you configure your Google Cloud Functions?, select your preferred method from the dropdown menu. Make sure you set all properties for the selected method before copying the generated configuration snippets.

Step 2 optional Specify a Dynatrace API endpoint optional

If you don't want to use the default public Dynatrace endpoint, specify a custom Dynatrace API endpoint where you want to receive monitoring data.

To reduce network latency, you typically deploy a Dynatrace ActiveGate close to (in the same region as) the Google Cloud function that you want to monitor.

Step 3 Apply the configuration to your Google Cloud function

Copy the JSON snippet into a file named dtconfig.json located in the root folder of your Google Cloud Functions deployment.

On Enable Monitoring for Google Cloud Functions, under Use the following values to configure your monitored Google Cloud Functions, there's a snippet with all required environment variables. Be sure to add these environment variables and their values to your Google Cloud function configuration. For details, see Using environment variables.

Step 4 Instrument the function code

Adding the required API calls to monitor function invocations via OpenTelemetry is specific to languages and their respective OpenTelemetry distribution:

Known limitations

The Dynatrace Google Cloud Functions integration doesn't capture the IP addresses of outgoing HTTP requests. If the called service isn't monitored with Dynatrace OneAgent, this results in unmonitored hosts.