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
Select a configuration method
Specify a Dynatrace API endpoint
Apply the configuration to your Google Cloud function
Instrument the function code
Select a configuration method
- In Dynatrace Hub, select OneAgent.
- Select Set up > Google Cloud Functions.
- 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.
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.
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.
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.