Tracing
In your main application, add the dd-trace-js
library. See Tracing Node.js applications for instructions.
Set ENV NODE_OPTIONS="--require dd-trace/init"
. This specifies that the dd-trace/init
module is required when the Node.js process starts.
Profiling
The profiler is shipped within Datadog tracing libraries. If you are already using APM to collect traces for your application, you can skip installing the library and proceed to enabling the profiler. See Enabling the Node.js Profiler to add the environment variables.
Metrics
The tracing library also collects custom metrics. See the code examples.
Logs
The Datadog sidecar collects logs through a shared volume. To forward logs from your main container to the sidecar, configure your application to write all logs to a location such as shared-volume/logs/*.log
using the steps below. During the container step, add the environment variable DD_SERVERLESS_LOG_PATH
and a shared Volume Mount to both the main and sidecar container.
To set up logging in your application, see Node.js Log Collection. To set up trace log correlation, see Correlating Node.js Logs and Traces.
Tracing
Download dd-java-agent.jar
that contains the latest tracer class files, to a folder that is accessible by your Datadog user:
When setting up your containers; Implement and Auto instrument the Java tracer by setting the environment variable to instrument your Java cloud function with the Datadog Java tracer.
Name | Value |
---|
JAVA_TOOL_OPTIONS | -javaagent:/path/to/dd-java-agent.jar |
Cloud Run Function code runs with a classpath that includes the function code and its dependencies.
If invoking the Functions Framework directly with the Datadog Agent, update the --classpath
and --target
options, along with the Java agent flag to the path of your jar files:
To run your app from an IDE, Maven, or Gradle application script, or java -javaagent
command, add the -javaagent
JVM argument and the following configuration options, as applicable:
java -javaagent:dd-java-agent.jar -jar java-function-invoker \
--classpath 'FUNCTION_JAR' \
--target 'FUNCTION_TARGET'
- Replace
FUNCTION_JAR
with the target JAR generated from the Maven build, including all dependencies. - Replace
FUNCTION_TARGET
with the function’s entry point (for example, gcfv2.HelloworldApplication
). - NOTE: You will also need to download the
java-function-invoker.jar
from the Maven repository to run your Java function locally in your terminal.
To deploy the Java function in your terminal, run the following gcloud command from the top-level source directory:
gcloud run deploy FUNCTION_NAME \
--source . \
--function FUNCTION_TARGET \
--base-image BASE_IMAGE \
--region REGION
- Replace
REGION
with the region where you want to deploy the function. - Replace
FUNCTION_TARGET
with your function entry point. For example, gcfv2.HelloworldApplication
. - Replace
FUNCTION_NAME
with the name of your Cloud Run function. - Replace
BASE_IMAGE
with the base image for the function. For example, java21
.
As an alternative to setting the environment variable
JAVA_TOOL_OPTIONS
in the console, you can use Artifact Registry to store the images built from your function source code utilizing the example Dockerfile. You can use
Google Cloud Build or
Buildpacks to build and deploy your image.
For example:
gcloud builds submit --pack image=LOCATION-docker.pkg.dev/PROJECT_ID/REPO_NAME/IMAGE_NAME
Profiling
The profiler is shipped within Datadog tracing libraries. If you are already using APM to collect traces for your application, you can skip installing the library and proceed to enabling the profiler. See Enabling the Java Profiler to add the environment variables.
Metrics
To collect custom metrics, install the Java DogStatsD client.
Logs
The Datadog sidecar collects logs through a shared volume. To forward logs from your main container to the sidecar, configure your application to write all logs to a location such as shared-volume/logs/*.log
using the steps below. During the container step, add the environment variable DD_SERVERLESS_LOG_PATH
and a shared Volume Mount to both the main and sidecar container.
To set up logging in your application, see Java Log Collection. To set up trace log correlation, see Correlating Java Logs and Traces.
Tracing
In your main application, add the dd-trace-go
library. See Tracing Go Applications for instructions.
Profiling
The profiler is shipped within Datadog tracing libraries. If you are already using APM to collect traces for your application, you can skip installing the library and proceed to enabling the profiler. See Enabling the Go Profiler to add the environment variables.
Metrics
The tracing library also collects custom metrics. See the code examples.
Logs
The Datadog sidecar collects logs through a shared volume. To forward logs from your main container to the sidecar, configure your application to write all logs to a location such as shared-volume/logs/*.log
using the steps below. During the container step, add the environment variable DD_SERVERLESS_LOG_PATH
and a shared Volume Mount to both the main and sidecar container.
To set up logging in your application, see Go Log Collection. To set up trace log correlation, see Correlating Go Logs and Traces.
Tracing
In your main application, add the .NET tracing library. See Tracing .NET Applications for instructions.
Profiling
The profiler is shipped within Datadog tracing libraries. If you are already using APM to collect traces for your application, you can skip installing the library and proceed to enabling the profiler. See Enabling the .NET Profiler to add the environment variables.
Metrics
The tracing library also collects custom metrics. See the code examples.
Logs
The Datadog sidecar collects logs through a shared volume. To forward logs from your main container to the sidecar, configure your application to write all logs to a location such as shared-volume/logs/*.log
using the steps below. During the container step, add the environment variable DD_SERVERLESS_LOG_PATH
and a shared Volume Mount to both the main and sidecar container.
To set up logging in your application, see C# Log Collection. To set up trace log correlation, see Correlating .NET Logs and Traces.