Información general

Google Cloud Run es una plataforma serverless totalmente gestionada que sirve para desplegar y escalar aplicaciones basadas en contenedores. Datadog ofrece monitorización y recopilación de logs para Cloud Run a través de la integración de Google Cloud. Datadog también brinda una solución para instrumentar las aplicaciones de Cloud Run con un Agent especialmente diseñado para habilitar el rastreo, las métricas personalizadas y la recopilación directa de logs.

Requisitos previos

Asegúrate de que dispones de una clave de la API de Datadog y de que utilizas un lenguaje de programación compatible con una biblioteca de rastreo de Datadog.

Instrumentar la aplicación

Puedes instrumentar tu aplicación de dos maneras: Dockerfile o buildpack.

Dockerfile

Datadog publica nuevas versiones de la imagen de contenedor serverless-init en gcr.io de Google, AWS ECR y Docker Hub:

dockerhub.iogcr.iopublic.ecr.aws
datadog/serverless-initgcr.io/datadoghq/serverless-initpublic.ecr.AWS/Datadog/serverless-init

Las imágenes se etiquetan en función del control de versiones semántico, y cada nueva versión recibe tres etiquetas (tags):

  • 1, 1-alpine: utilízalas para hacer un seguimiento de las últimas versiones secundarias, sin cambios importantes.
  • 1.x.x, 1.x.x-alpine: utilízalas para fijar una versión precisa de la biblioteca.
  • latest, latest-alpine: utilízalas para hacer un seguimiento de la última versión, que puede incluir cambios importantes.

Cómo funciona serverless-init

La aplicación serverless-init envuelve tu proceso y lo ejecuta como un subproceso. Inicia un agente de escucha de DogStatsD para las métricas y un agente de escucha de Trace Agent para las trazas (traces). Envuelve los flujos stdout/stderr de tu aplicación para recuperar los logs. Después del arranque, serverless-init lanza tu comando como un subproceso.

Para obtener una instrumentación completa, asegúrate de llamar a datadog-init como el primer comando que se ejecuta dentro de tu contenedor de Docker. Puedes hacerlo si configuras datadog-init como el punto de entrada o como el primer argumento en el CMD.

Add the following instructions and arguments to your Dockerfile.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
RUN npm install --prefix /dd_tracer/node dd-trace  --save
ENV DD_SERVICE=datadog-demo-run-nodejs
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["/nodejs/bin/node", "/path/to/your/app.js"]

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
    
  2. Copy the Datadog Node.JS tracer into your Docker image.

    RUN npm install --prefix /dd_tracer/node dd-trace  --save
    

    If you install the Datadog tracer library directly in your application, as outlined in the manual tracer instrumentation instructions, omit this step.

  3. (Optional) Add Datadog tags.

    ENV DD_SERVICE=datadog-demo-run-nodejs
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  4. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.

    CMD ["/nodejs/bin/node", "/path/to/your/app.js"]
    

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
RUN npm install --prefix /dd_tracer/node dd-trace  --save
ENV DD_SERVICE=datadog-demo-run-nodejs
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
RUN npm install --prefix /dd_tracer/node dd-trace  --save
ENV DD_SERVICE=datadog-demo-run-nodejs
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["/your_entrypoint.sh", "/nodejs/bin/node", "/path/to/your/app.js"]

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Add the following instructions and arguments to your Dockerfile.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
RUN pip install --target /dd_tracer/python/ ddtrace
ENV DD_SERVICE=datadog-demo-run-python
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "app.py"]

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
    
  2. Install the Datadog Python tracer.

    RUN pip install --target /dd_tracer/python/ ddtrace
    

    If you install the Datadog tracer library directly in your application, as outlined in the manual tracer instrumentation instructions, omit this step.

  3. (Optional) Add Datadog tags.

    ENV DD_SERVICE=datadog-demo-run-python
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  4. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  5. Execute your binary application wrapped in the entrypoint, launched by the Datadog trace library. Adapt this line to your needs.

    CMD ["/dd_tracer/python/bin/ddtrace-run", "python", "app.py"]
    

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
RUN pip install --target /dd_tracer/python/ ddtrace
ENV DD_SERVICE=datadog-demo-run-python
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
CMD ["/app/datadog-init", "/dd_tracer/python/bin/ddtrace-run", "python", "app.py"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
RUN pip install --target /dd_tracer/python/ ddtrace
ENV DD_SERVICE=datadog-demo-run-python
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["your_entrypoint.sh", "/dd_tracer/python/bin/ddtrace-run", "python", "app.py"]

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Add the following instructions and arguments to your Dockerfile.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ADD 'https://dtdg.co/latest-java-tracer' /dd_tracer/java/dd-java-agent.jar
ENV DD_SERVICE=datadog-demo-run-java
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["./mvnw", "spring-boot:run"]

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
    
  2. Add the Datadog Java tracer to your Docker image.

    ADD 'https://dtdg.co/latest-java-tracer' /dd_tracer/java/dd-java-agent.jar
    

    If you install the Datadog tracer library directly in your application, as outlined in the manual tracer instrumentation instructions, omit this step.

  3. (Optional) Add Datadog tags.

    ENV DD_SERVICE=datadog-demo-run-java
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  4. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.

    CMD ["./mvnw", "spring-boot:run"]
    

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ADD 'https://dtdg.co/latest-java-tracer' /dd_tracer/java/dd-java-agent.jar
ENV DD_SERVICE=datadog-demo-run-java
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
CMD ["/app/datadog-init", "./mvnw", "spring-boot:run"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ADD 'https://dtdg.co/latest-java-tracer' /dd_tracer/java/dd-java-agent.jar
ENV DD_SERVICE=datadog-demo-run-java
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["your_entrypoint.sh", "./mvnw", "spring-boot:run"]

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Manually install the Go tracer before you deploy your application. Add the following instructions and arguments to your Dockerfile.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENTRYPOINT ["/app/datadog-init"]
ENV DD_SERVICE=datadog-demo-run-go
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
CMD ["/path/to/your-go-binary"]

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
    
  2. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  3. (Optional) Add Datadog tags.

    ENV DD_SERVICE=datadog-demo-run-go
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  4. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.

    CMD ["/path/to/your-go-binary"]
    

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENV DD_SERVICE=datadog-demo-run-go
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
CMD ["/app/datadog-init", "/path/to/your-go-binary"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENV DD_SERVICE=datadog-demo-run-go
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["your_entrypoint.sh", "/path/to/your-go-binary"]

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Note: You can also use Orchestrion, a tool for automatically instrumenting Go code. Orchestrion is in private beta. For more information, open a GitHub issue in the Orchestrion repo, or contact Support.

Add the following instructions and arguments to your Dockerfile.

# For alpine or arm64 builds, refer to the explanation section
COPY --from=datadog/serverless-init:1 / /app/
RUN chmod +x /app/dotnet.sh && /app/dotnet.sh

ENV DD_SERVICE=datadog-demo-run-dotnet
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["dotnet", "helloworld.dll"]

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 / /app/
    
  2. Copy the Datadog .NET tracer into your Docker image. For linux/amd64, include the following:

    RUN chmod +x /app/dotnet.sh && /app/dotnet.sh
    

    For other architecture types, configure your Dockerfile like so:

    # For arm64 use datadog-dotnet-apm-2.57.0.arm64.tar.gz
    # For alpine use datadog-dotnet-apm-2.57.0-musl.tar.gz
    ARG TRACER_VERSION
    ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm-${TRACER_VERSION}.tar.gz /tmp/datadog-dotnet-apm.tar.gz
    
    RUN mkdir -p /dd_tracer/dotnet/ && tar -xzvf /tmp/datadog-dotnet-apm.tar.gz -C /dd_tracer/dotnet/ && rm /tmp/datadog-dotnet-apm.tar.gz
    

    If you install the Datadog tracer library directly in your application, as outlined in the manual tracer instrumentation instructions, omit this step.

  3. (Optional) Add Datadog tags.

    ENV DD_SERVICE=datadog-demo-run-dotnet
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  4. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.

    CMD ["dotnet", "helloworld.dll"]
    

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument.

# For alpine or arm64 builds, refer to tracer installation of the explanation section
COPY --from=datadog/serverless-init:1 / /app/
RUN chmod +x /app/dotnet.sh && /app/dotnet.sh

ENV DD_SERVICE=datadog-demo-run-dotnet
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
CMD ["/app/datadog-init", "dotnet", "helloworld.dll"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

# For alpine or arm64 builds, refer to tracer installation of the explanation section
COPY --from=datadog/serverless-init:1 / /app/
RUN chmod +x /app/dotnet.sh && /app/dotnet.sh

ENV DD_SERVICE=datadog-demo-run-dotnet
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]
CMD ["your_entrypoint.sh", "dotnet", "helloworld.dll"]

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Manually install the Ruby tracer before you deploy your application. See the example application.

Add the following instructions and arguments to your Dockerfile.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENV DD_SERVICE=datadog-demo-run-ruby
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENV DD_TRACE_PROPAGATION_STYLE=datadog
ENTRYPOINT ["/app/datadog-init"]
CMD ["rails", "server", "-b", "0.0.0.0"]

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
    
  2. (Optional) add Datadog tags

    ENV DD_SERVICE=datadog-demo-run-ruby
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  3. This environment variable is needed for trace propagation to work properly in Cloud Run. Ensure that you set this variable for all Datadog-instrumented downstream services.

    ENV DD_TRACE_PROPAGATION_STYLE=datadog
    
  4. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  5. Execute your binary application wrapped in the entrypoint. Adapt this line to your needs.

    CMD ["rails", "server", "-b", "0.0.0.0"]
    

Alternative configuration

If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENV DD_SERVICE=datadog-demo-run-ruby
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENV DD_TRACE_PROPAGATION_STYLE=datadog
CMD ["/app/datadog-init", "rails", "server", "-b", "0.0.0.0"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ENV DD_SERVICE=datadog-demo-run-ruby
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENV DD_TRACE_PROPAGATION_STYLE=datadog
ENTRYPOINT ["/app/datadog-init"]
CMD ["your_entrypoint.sh", "rails", "server", "-b", "0.0.0.0"]

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Add the following instructions and arguments to your Dockerfile.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ADD https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php /datadog-setup.php
RUN php /datadog-setup.php --php-bin=all
ENV DD_SERVICE=datadog-demo-run-php
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]

# use the following for an Apache and mod_php based image
RUN sed -i "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf
EXPOSE 8080
CMD ["apache2-foreground"]

# use the following for an Nginx and php-fpm based image
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 8080
CMD php-fpm; nginx -g daemon off;

Note: The datadog-init entrypoint wraps your process and collects logs from it. To get logs working properly, ensure that your Apache, Nginx, or PHP processes are writing output to stdout.

Explanation

  1. Copy the Datadog serverless-init into your Docker image.

    COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
    
  2. Copy and install the Datadog PHP tracer.

    ADD https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php /datadog-setup.php
    RUN php /datadog-setup.php --php-bin=all
    

    If you install the Datadog tracer library directly in your application, as outlined in the manual tracer instrumentation instructions, omit this step.

  3. (Optional) Add Datadog tags.

    ENV DD_SERVICE=datadog-demo-run-php
    ENV DD_ENV=datadog-demo
    ENV DD_VERSION=1
    
  4. Change the entrypoint to wrap your application in the Datadog serverless-init process. Note: If you already have an entrypoint defined inside your Dockerfile, see the alternative configuration.

    ENTRYPOINT ["/app/datadog-init"]
    
  5. Execute your application.

    Use the following for an apache and mod_php based image:

    RUN sed -i "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf
    EXPOSE 8080
    CMD ["apache2-foreground"]
    

    Use the following for an nginx and php-fpm based image:

    RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
    EXPOSE 8080
    CMD php-fpm; nginx -g daemon off;
    

Alternative configuration: CMD argument

If you already have an entrypoint defined inside your Dockerfile, and you are using an Apache and mod_php based image, you can instead modify the CMD argument.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ADD https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php /datadog-setup.php
RUN php /datadog-setup.php --php-bin=all
ENV DD_SERVICE=datadog-demo-run-php
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
RUN sed -i "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf
EXPOSE 8080
CMD ["/app/datadog-init", "apache2-foreground"]

If you require your entrypoint to be instrumented as well, you can swap your entrypoint and CMD arguments instead. For more information, see How serverless-init works.

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init
ADD https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php /datadog-setup.php
RUN php /datadog-setup.php --php-bin=all
ENV DD_SERVICE=datadog-demo-run-php
ENV DD_ENV=datadog-demo
ENV DD_VERSION=1
ENTRYPOINT ["/app/datadog-init"]

# use the following for an Apache and mod_php based image
RUN sed -i "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf
EXPOSE 8080
CMD ["your_entrypoint.sh", "apache2-foreground"]

# use the following for an Nginx and php-fpm based image
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 8080
CMD your_entrypoint.sh php-fpm; your_entrypoint.sh nginx -g daemon off;

As long as your command to run is passed as an argument to datadog-init, you will receive full instrumentation.

Buildpack

Pack Buildpacks ofrece una manera conveniente de empaquetar un contenedor sin utilizar un Dockerfile.

Primero, instala manualmente tu rastreador:

Luego, ejecuta el siguiente comando para compilar tu aplicación:

pack build --builder=gcr.io/buildpacks/builder \
--buildpack from=builder \
--buildpack datadog/serverless-buildpack:latest \
gcr.io/YOUR_PROJECT/YOUR_APP_NAME

Nota: La instrumentación con buildpack no es compatible con imágenes de Alpine.

Configurar la aplicación

Una vez que el contenedor se ha creado y enviado al registro, el último paso consiste en configurar las variables de entorno obligatorias del Datadog Agent:

  • DD_API_KEY: la clave de la API de Datadog, utilizada para enviar datos a tu cuenta de Datadog. Debe configurarse como un secreto de Google Cloud por cuestiones de privacidad y seguridad.
  • DD_SITE: el endpoint y el sitio web de Datadog. Selecciona tu sitio en la parte derecha de esta página. Tu sitio es: .
  • DD_TRACE_ENABLED: defínela como true para habilitar el rastreo.
  • DD_TRACE_PROPAGATION_STYLE: defínela como datadog para utilizar la propagación de contexto y la correlación de trazas con logs.

Para obtener más información sobre las variables de entorno y sus funciones, consulta Configuraciones adicionales.

El siguiente comando despliega el servicio y permite que cualquier conexión externa lo alcance. Define DD_API_KEY como una variable de entorno y configura tu servicio para que escuche en el puerto 8080.

shell
gcloud run deploy APP_NAME --image=gcr.io/YOUR_PROJECT/APP_NAME \
  --port=8080 \
  --update-env-vars=DD_API_KEY=$DD_API_KEY \
  --update-env-vars=DD_TRACE_ENABLED=true \
  --update-env-vars=DD_SITE='datadoghq.com' \
  --update-env-vars=DD_TRACE_PROPAGATION_STYLE='datadog' \

Resultados

Una vez completado el despliegue, tus métricas y trazas se envían a Datadog. En Datadog, navega hasta Infrastructure->Serverless (Infraestructura->Serverless) para ver tus métricas y trazas serverless.

Configuraciones adicionales

  • Rastreo avanzado: el Datadog Agent ya proporciona un rastreo básico para los marcos más populares. Sigue la guía de rastreo avanzado para obtener más información.

  • Logs: si utilizas la integración de Google Cloud, tus logs ya se recopilan. Como alternativa, puedes definir la variable de entorno DD_LOGS_ENABLED como true para capturar los logs de aplicación directamente a través de la instrumentación serverless.

  • Métricas personalizadas: puedes enviar métricas personalizadas mediante un cliente de DogStatsD. Para monitorizar Cloud Run y otras aplicaciones serverless, utiliza métricas de distribución. Las distribuciones ofrecen las agregaciones predeterminadas avg, sum, max, min y count. En la página Metric Summary (Resumen de métrica), puedes habilitar las agregaciones percentiles (p50, p75, p90, p95, p99) y también gestionar etiquetas. Para monitorizar una distribución para un tipo de métrica gauge, utiliza avg tanto para las agregaciones temporales como espaciales. Para monitorizar una distribución para un tipo de métrica count, utiliza sum tanto para las agregaciones temporales como espaciales.

Variables de entorno

VariableDescripción
DD_API_KEYLa clave de la API de Datadog: obligatoria.
DD_SITEEl sitio de Datadog: obligatorio.
DD_LOGS_ENABLEDCuando es true, envía logs (stdout y stderr) a Datadog. Por defecto, es false.
DD_LOGS_INJECTIONCuando es true, enriquece todos los logs con datos de trazas para los loggers admitidos en Java, Node.js, .NET y PHP. Consulta la documentación adicional de Python, Go y Ruby.
DD_TRACE_SAMPLE_RATEControla las frecuencias de muestreo de la ingesta de trazas 0.0 y 1.0.
DD_SERVICEConsulta Etiquetado de servicios unificado.
DD_VERSIONConsulta Etiquetado de servicios unificado.
DD_ENVConsulta Etiquetado de servicios unificado.
DD_SOURCEConsulta Etiquetado de servicios unificado.
DD_TAGSConsulta Etiquetado de servicios unificado.

Solucionar problemas

Esta integración depende de que tu tiempo de ejecución tenga una implementación SSL completa. Si estás usando una imagen slim, es posible que debas añadir el siguiente comando a tu Dockerfile para incluir certificados.

RUN apt-get update && apt-get install -y ca-certificates

Referencias adicionales

Additional helpful documentation, links, and articles: