From a29c7a64bec8d7fa0d3eb7746c120d26721de9c4 Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Mon, 20 Jul 2026 11:12:26 -0400 Subject: [PATCH 01/12] Consolidate Azure Container Apps instrumentation into a single Cdocs page Replace the separate in-container and sidecar per-language pages with one filterable Cdocs page driven by instrumentation_method and prog_lang content filters. Extract shared serverless-init content into Markdoc partials, add the instrumentation_method trait and serverless option groups, and remove the now orphaned _index translations. Co-Authored-By: Claude Opus 4.8 (1M context) --- content/.gitignore | 1 + .../serverless/azure_container_apps/_index.md | 56 - .../azure_container_apps/_index.mdoc.md | 1109 +++++++++++++++++ .../in_container/_index.md | 14 - .../in_container/dotnet.md | 91 -- .../azure_container_apps/in_container/go.md | 86 -- .../azure_container_apps/in_container/java.md | 103 -- .../in_container/nodejs.md | 89 -- .../azure_container_apps/in_container/php.md | 69 - .../in_container/python.md | 104 -- .../azure_container_apps/in_container/ruby.md | 72 -- .../azure_container_apps/sidecar/_index.md | 12 - .../azure_container_apps/sidecar/dotnet.md | 115 -- .../azure_container_apps/sidecar/go.md | 111 -- .../azure_container_apps/sidecar/java.md | 124 -- .../azure_container_apps/sidecar/nodejs.md | 110 -- .../azure_container_apps/sidecar/php.md | 102 -- .../azure_container_apps/sidecar/python.md | 123 -- .../azure_container_apps/sidecar/ruby.md | 93 -- .../serverless/azure_container_apps/_index.md | 457 ------- .../serverless/azure_container_apps/_index.md | 162 --- .../serverless/azure_container_apps/_index.md | 291 ----- .../en/option_groups/serverless.yaml | 18 + customization_config/en/options/general.yaml | 6 + .../en/traits/serverless.yaml | 5 + .../aca-sidecar-install-methods.mdoc.md | 411 ++++++ .../serverless-init-configure.mdoc.md | 14 + ...verless-init-env-vars-in-container.mdoc.md | 28 + .../serverless-init-env-vars-sidecar.mdoc.md | 26 + .../serverless/serverless-init-image.mdoc.md | 16 + .../serverless-init-troubleshooting.mdoc.md | 24 + .../en/serverless/svl-tracing-env.mdoc.md | 9 + 32 files changed, 1667 insertions(+), 2384 deletions(-) delete mode 100644 content/en/serverless/azure_container_apps/_index.md create mode 100644 content/en/serverless/azure_container_apps/_index.mdoc.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/_index.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/dotnet.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/go.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/java.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/nodejs.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/php.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/python.md delete mode 100644 content/en/serverless/azure_container_apps/in_container/ruby.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/_index.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/dotnet.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/go.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/java.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/nodejs.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/php.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/python.md delete mode 100644 content/en/serverless/azure_container_apps/sidecar/ruby.md delete mode 100644 content/es/serverless/azure_container_apps/_index.md delete mode 100644 content/ja/serverless/azure_container_apps/_index.md delete mode 100644 content/ko/serverless/azure_container_apps/_index.md create mode 100644 customization_config/en/option_groups/serverless.yaml create mode 100644 customization_config/en/traits/serverless.yaml create mode 100644 layouts/shortcodes/mdoc/en/serverless/aca-sidecar-install-methods.mdoc.md create mode 100644 layouts/shortcodes/mdoc/en/serverless/serverless-init-configure.mdoc.md create mode 100644 layouts/shortcodes/mdoc/en/serverless/serverless-init-env-vars-in-container.mdoc.md create mode 100644 layouts/shortcodes/mdoc/en/serverless/serverless-init-env-vars-sidecar.mdoc.md create mode 100644 layouts/shortcodes/mdoc/en/serverless/serverless-init-image.mdoc.md create mode 100644 layouts/shortcodes/mdoc/en/serverless/serverless-init-troubleshooting.mdoc.md create mode 100644 layouts/shortcodes/mdoc/en/serverless/svl-tracing-env.mdoc.md diff --git a/content/.gitignore b/content/.gitignore index c39776db64b..a7a8424bd37 100644 --- a/content/.gitignore +++ b/content/.gitignore @@ -104,3 +104,4 @@ /*/tracing/trace_collection/custom_instrumentation/server-side/_index.md /*/dd_e2e/cdocs/components/card_grid.md /*/real_user_monitoring/application_monitoring/browser/setup/_index.md +/*/serverless/azure_container_apps/_index.md diff --git a/content/en/serverless/azure_container_apps/_index.md b/content/en/serverless/azure_container_apps/_index.md deleted file mode 100644 index 97f5cff1b60..00000000000 --- a/content/en/serverless/azure_container_apps/_index.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: Azure Container Apps -further_reading: - - link: "/serverless/guide/disable_serverless" - tag: "Documentation" - text: "Disable Serverless Monitoring" - - link: 'https://www.datadoghq.com/blog/azure-container-apps/' - tag: 'Blog' - text: 'Collect traces, logs, and custom metrics from Container Apps services' - - link: 'http://datadoghq.com/blog/azure-well-architected-serverless-applications-best-practices/' - tag: 'Blog' - text: 'Build secure and scalable Azure serverless applications with the Well-Architected Framework' - - link: "/integrations/azure/" - tag: "Documentation" - text: "Azure Integration" - - link: "/serverless/azure_container_apps/in_container/" - tag: 'Documentation' - text: 'Instrument your container with the in-container approach' - - link: "/serverless/azure_container_apps/sidecar/" - tag: 'Documentation' - text: 'Instrument your container with the sidecar approach' ---- - -## Overview -Azure Container Apps is a fully managed serverless platform for deploying and scaling container-based applications. Datadog provides standard metrics and log collection for Container Apps through the [Azure integration][1]. Datadog also provides a solution for instrumenting your Container Apps applications with a Serverless Agent to enable tracing, enhanced metrics, custom metrics, and direct log collection. [Enhanced metrics][4] are distinguished with the `azure.app_containerapps.enhanced.*` namespace. - -{{< img src="serverless/azure_container_apps/aca_top_2.png" alt="Datadog UI, Serverless Monitoring page with Azure Container Apps selected." style="width:100%;" >}} - -## Choosing an Instrumentation Method - -To instrument your Azure Container App with Datadog, choose one of two options: - -{{% aca-container-options %}} - -- [**In-Container**][2]: Wraps your application container with the Datadog Agent. Choose this option for a simpler setup, lower cost overhead, and direct log piping. -- [**Sidecar**][3]: Deploys the Datadog Agent in a separate container alongside your app container. Choose this option if you have multiple containers in a single service, if you prefer strict isolation of the Datadog Agent, or if you have performance-sensitive workloads. - -## Comparison: In-Container versus sidecar instrumentation - -| Aspect | In-Container | Sidecar | -|-------------------------------|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Deployment | One container (your app, wrapped with the Datadog Agent) | Two containers (your app, Datadog Agent) | -| Image changes | Increases app image size. | No change to app image. | -| Cost overhead | Less than sidecar (no extra container). | Extra vCPU/memory. Overallocating the sidecar wastes cost; underallocating leads to premature scaling. | -| Logging | Direct stdout/stderr access. | Shared volume + log library routing to a log file. Uncaught errors require extra handling, since they are not automatically handled by your logging library. | -| Failure isolation | In rare cases, Datadog Agent bugs can affect your app. | Datadog Agent faults are isolated. | - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - - -[1]: /integrations/azure/#log-collection -[2]: /serverless/azure_container_apps/in_container -[3]: /serverless/azure_container_apps/sidecar -[4]: /integrations/azure-container-apps/#metrics diff --git a/content/en/serverless/azure_container_apps/_index.mdoc.md b/content/en/serverless/azure_container_apps/_index.mdoc.md new file mode 100644 index 00000000000..cc559ab5bae --- /dev/null +++ b/content/en/serverless/azure_container_apps/_index.mdoc.md @@ -0,0 +1,1109 @@ +--- +title: Azure Container Apps +content_filters: + - trait_id: instrumentation_method + option_group_id: aca_instrumentation_method_options + label: "Instrumentation method" + - trait_id: prog_lang + option_group_id: aca_runtime_options + label: "Runtime" +aliases: + - /serverless/guide/aca_serverless_init/ + - /serverless/azure_container_apps/in_container/ + - /serverless/azure_container_apps/in_container/python/ + - /serverless/azure_container_apps/in_container/nodejs/ + - /serverless/azure_container_apps/in_container/go/ + - /serverless/azure_container_apps/in_container/java/ + - /serverless/azure_container_apps/in_container/dotnet/ + - /serverless/azure_container_apps/in_container/ruby/ + - /serverless/azure_container_apps/in_container/php/ + - /serverless/azure_container_apps/sidecar/ + - /serverless/azure_container_apps/sidecar/python/ + - /serverless/azure_container_apps/sidecar/nodejs/ + - /serverless/azure_container_apps/sidecar/go/ + - /serverless/azure_container_apps/sidecar/java/ + - /serverless/azure_container_apps/sidecar/dotnet/ + - /serverless/azure_container_apps/sidecar/ruby/ + - /serverless/azure_container_apps/sidecar/php/ +further_reading: + - link: "/serverless/guide/disable_serverless" + tag: "Documentation" + text: "Disable Serverless Monitoring" + - link: 'https://www.datadoghq.com/blog/azure-container-apps/' + tag: 'Blog' + text: 'Collect traces, logs, and custom metrics from Container Apps services' + - link: 'http://datadoghq.com/blog/azure-well-architected-serverless-applications-best-practices/' + tag: 'Blog' + text: 'Build secure and scalable Azure serverless applications with the Well-Architected Framework' + - link: "/integrations/azure/" + tag: "Documentation" + text: "Azure Integration" +--- + +{% collapse-content title="Compare methods" level="h5" %} + +| Aspect | In-Container | Sidecar | +|--------|--------------|---------| +| Deployment | One container (your app, wrapped with the Datadog Agent) | Two containers (your app, Datadog Agent) | +| Image changes | Increases app image size. | No change to app image. | +| Cost overhead | Less than sidecar (no extra container). | Extra vCPU/memory. Overallocating the sidecar wastes cost; underallocating leads to premature scaling. | +| Logging | Direct stdout/stderr access. | Shared volume + log library routing to a log file. Uncaught errors require extra handling, since they are not automatically handled by your logging library. | +| Failure isolation | In rare cases, Datadog Agent bugs can affect your app. | Datadog Agent faults are isolated. | +| Best for | Simpler setup, lower cost, and direct log piping. | Multiple containers per service, Agent isolation, and performance-sensitive workloads. | + +{% /collapse-content %} + +## Setup + + +{% if equals($instrumentation_method, "in_container") %} + + +{% if equals($prog_lang, "python") %} +{% stepper %} +{% step title="Install the Datadog Python SDK" %} +Add `ddtrace` to your `requirements.txt` or `pyproject.toml`. You can find the latest version on [PyPI](https://pypi.org/project/ddtrace/): + +```text {% filename="requirements.txt" %} +ddtrace== +``` + +Alternatively, you can install the SDK in your Dockerfile: + +```dockerfile {% filename="Dockerfile" %} +RUN pip install ddtrace +``` + +Then, wrap your start command with `ddtrace-run`: + +```dockerfile {% filename="Dockerfile" %} +CMD ["ddtrace-run", "python", "app.py"] +``` + +For more information, see [Tracing Python applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/python). +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["ddtrace-run", "python", "path/to/your/python/app.py"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "ddtrace-run", "python", "path/to/your/python/app.py"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "ddtrace-run", "python", "path/to/your/python/app.py"] +``` + +As long as your command to run is passed as an argument to `datadog-init`, you receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends the following environment variables: +- `ENV PYTHONUNBUFFERED=1`: Makes Python output appear immediately in container logs instead of being buffered. +- `ENV DD_LOGS_INJECTION=true`: Enable log/trace correlation for supported loggers. +- `ENV DD_SOURCE=python`: Enable advanced Datadog log parsing. + +If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `structlog`: + +```python +import structlog + +def tracer_injection(logger, log_method, event_dict): + event_dict.update(tracer.get_log_correlation_context()) + return event_dict + +structlog.configure( + processors=[ + tracer_injection, + structlog.processors.EventRenamer("msg"), + structlog.processors.JSONRenderer() + ], + logger_factory=structlog.WriteLoggerFactory(file=sys.stdout), +) + +logger = structlog.get_logger() + +logger.info("Hello world!") +``` + +For more information, see [Correlating Python Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/python/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=python#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=python#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% step title="Enable profiling (preview)" %} +To enable the [Continuous Profiler](/profiler/), set the environment variable `DD_PROFILING_ENABLED=true`. + +{% alert %} +Datadog's Continuous Profiler is available in preview for Azure Container Apps. +{% /alert %} +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "node_js") %} +{% stepper %} +{% step title="Install the Datadog Node.js SDK" %} +In your main application, install the `dd-trace` package. + +```shell +npm install dd-trace +``` + +Initialize the Node.js tracer with the `NODE_OPTIONS` environment variable: + +```dockerfile {% filename="Dockerfile" %} +ENV NODE_OPTIONS="--require dd-trace/init" +``` + +For more information, see [Tracing Node.js applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/). +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["/nodejs/bin/node", "/path/to/your/app.js"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "/nodejs/bin/node", "/path/to/your/app.js"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +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 receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends setting the environment variables `DD_LOGS_INJECTION=true` and `DD_SOURCE=nodejs` to enable advanced Datadog log parsing. + +If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `winston`: + +```javascript +const { createLogger, format, transports } = require('winston'); + +const logger = createLogger({ + level: 'info', + exitOnError: false, + format: format.json(), + transports: [ + new transports.Console() + ], +}); + +logger.info('Hello world!'); +``` + +For more information, see [Correlating Node.js Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/nodejs/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% step title="Enable profiling (preview)" %} +To enable the [Continuous Profiler](/profiler/), set the environment variable `DD_PROFILING_ENABLED=true`. + +{% alert %} +Datadog's Continuous Profiler is available in preview for Azure Container Apps. +{% /alert %} +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "go") %} +{% stepper %} +{% step title="Install the Datadog Go SDK" %} +In your main application, add the SDK from `dd-trace-go`. + +```shell +go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer +``` + +Add the following to your application code to initialize the tracer: + +```go +tracer.Start() +defer tracer.Stop() +``` + +You can also add additional packages: + +```shell +# Enable Profiling +go get github.com/DataDog/dd-trace-go/v2/profiler + +# Patch /net/http +go get github.com/DataDog/dd-trace-go/contrib/net/http/v2 +``` + +For more information, see [Tracing Go Applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/) and the [Tracer README](https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#installing). +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["./your-binary"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "./your-binary"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "./your-binary"] +``` + +As long as your command to run is passed as an argument to `datadog-init`, you receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends setting the environment variable `DD_SOURCE=go` to enable advanced Datadog log parsing. + +If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `logrus`: + +```go +logrus.SetFormatter(&logrus.JSONFormatter{}) +logrus.AddHook(&dd_logrus.DDContextLogHook{}) + +logrus.WithContext(ctx).Info("Hello World!") +``` + +For more information, see [Correlating Go Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/go/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=go#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=go#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "java") %} +{% stepper %} +{% step title="Install the Datadog Java SDK" %} +Add the Datadog Java SDK to your Dockerfile: + +```dockerfile {% filename="Dockerfile" %} +ADD 'https://dtdg.co/latest-java-tracer' agent.jar +ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar" +``` + +Add the SDK artifacts. + +{% tabs %} +{% tab label="Maven" %} +```xml + + com.datadoghq + dd-trace-api + DD_TRACE_JAVA_VERSION_HERE + +``` +{% /tab %} +{% tab label="Gradle" %} +```groovy +implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' +``` +{% /tab %} +{% /tabs %} + +See [dd-trace-java releases](https://github.com/DataDog/dd-trace-java/releases) for the latest tracer version. + +Add the `@Trace` annotation to any method you want to trace. + +For more information, see [Tracing Java Applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/). +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["./mvnw", "spring-boot:run"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "./mvnw", "spring-boot:run"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +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 receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends setting the environment variables `DD_LOGS_INJECTION=true` and `DD_SOURCE=java` to enable advanced Datadog log parsing. + +If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in *compact* JSON format. For example, you can use a third-party logging library such as `Log4j 2`: + +```java +private static final Logger logger = LogManager.getLogger(App.class); +logger.info("Hello World!"); +``` + +```xml {% filename="resources/log4j2.xml" %} + + + + + + +``` + +For more information, see [Correlating Java Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/java/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=java#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=java#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "dot_net") %} +{% stepper %} +{% step title="Install the Datadog .NET SDK" %} +Install the Datadog .NET SDK in your Dockerfile. + +Because GitHub requests are rate limited, you must pass a GitHub token saved in the environment variable `GITHUB_TOKEN` as a [Docker build secret](https://docs.docker.com/build/building/secrets/) `--secret id=github-token,env=GITHUB_TOKEN`. + +{% tabs %} +{% tab label="Standard Linux (glibc)" %} +```dockerfile {% filename="Dockerfile" %} +RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \ + chmod +x /app/dotnet.sh && /app/dotnet.sh +``` +{% /tab %} +{% tab label="Alpine (musl)" %} +```dockerfile {% filename="Dockerfile" %} +# 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 +``` +{% /tab %} +{% /tabs %} + +For more information, see [Tracing .NET applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux). +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["dotnet", "dotnet.dll"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "dotnet", "dotnet.dll"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "dotnet", "dotnet.dll"] +``` + +As long as your command to run is passed as an argument to `datadog-init`, you receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends setting the environment variables `DD_LOGS_INJECTION=true` and `DD_SOURCE=csharp` to enable advanced Datadog log parsing. + +If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `Serilog`: + +```csharp +using Serilog; + +builder.Host.UseSerilog((context, config) => +{ + config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true)); +}); + +logger.LogInformation("Hello World!"); +``` + +For more information, see [Correlating .NET Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/dotnet/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=dotnet#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=dotnet#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "ruby") %} +{% stepper %} +{% step title="Install the Datadog Ruby SDK" %} +Add the `datadog` gem to your Gemfile: + +```ruby {% filename="Gemfile" %} +source 'https://rubygems.org' +gem 'datadog' +``` + +See [Tracing Ruby applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#instrument-your-application) for additional information on how to configure the SDK and enable auto instrumentation. +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["rails", "server", "-b", "0.0.0.0"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "rails", "server", "-b", "0.0.0.0"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +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 receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends setting the environment variable `DD_SOURCE=ruby` to enable advanced Datadog log parsing. + +To enable log-trace correlation, you need to include `Datadog::Tracing.log_correlation` in your log format. For example: + +```ruby +logger = Logger.new(STDOUT) +logger.formatter = proc do |severity, datetime, progname, msg| + "[#{datetime}] #{severity}: [#{Datadog::Tracing.log_correlation}] #{msg}\n" +end + +logger.info "Hello world!" +``` + +For more information, see [Correlating Ruby Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/ruby/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=ruby#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=ruby#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "php") %} +{% stepper %} +{% step title="Install the Datadog PHP SDK" %} +Install the Datadog PHP SDK in your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ + && php datadog-setup.php --php-bin=all +``` + +When running the `datadog-setup.php` script, you can also enable Application Security and Profiling by using the `--enable-appsec` and `--enable-profiling` flags, respectively. + +If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: + +```shell +apk add libgcc +``` + +For more information, see [Tracing PHP applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/php/). +{% /step %} +{% step title="Install serverless-init" %} +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +Add the following instructions and arguments to your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +COPY --from=datadog/serverless-init: /datadog-init /app/datadog-init +ENTRYPOINT ["/app/datadog-init"] +CMD ["apache2-foreground"] +``` + +{% collapse-content title="Alternative configuration" level="h4" %} +Datadog expects `serverless-init` to be the top-level application, with the rest of your app's command line passed in for `serverless-init` to execute. + +If you already have an entrypoint defined inside your Dockerfile, you can instead modify the CMD argument. + +```dockerfile +CMD ["/app/datadog-init", "apache2-foreground"] +``` + +If you require your entrypoint to be instrumented as well, you can instead swap your entrypoint and CMD arguments. + +```dockerfile +ENTRYPOINT ["/app/datadog-init"] +CMD ["/your_entrypoint.sh", "apache2-foreground"] +``` + +As long as your command to run is passed as an argument to `datadog-init`, you receive full instrumentation. +{% /collapse-content %} +{% /step %} +{% step title="Set up logs" %} +To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. + +Datadog also recommends setting the environment variables `DD_LOGS_INJECTION=true` and `DD_SOURCE=php` to enable advanced Datadog log parsing. + +For more information, see [Correlating PHP Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/php/). +{% /step %} +{% step title="Configure your application" %} +{% partial file="serverless/serverless-init-configure.mdoc.md" /%} +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=php#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=php#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + +{% /if %} + + + +{% if equals($instrumentation_method, "sidecar") %} + + +{% if equals($prog_lang, "python") %} +{% stepper %} +{% step title="Install the Datadog Python SDK" %} +Add `ddtrace` to your `requirements.txt` or `pyproject.toml`. You can find the latest version on [PyPI](https://pypi.org/project/ddtrace/): + +```text {% filename="requirements.txt" %} +ddtrace== +``` + +Alternatively, you can install the SDK in your Dockerfile: + +```dockerfile {% filename="Dockerfile" %} +RUN pip install ddtrace +``` + +Then, wrap your start command with `ddtrace-run`: + +```dockerfile {% filename="Dockerfile" %} +CMD ["ddtrace-run", "python", "app.py"] +``` + +For more information, see [Tracing Python applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/python). +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. You can also set a custom format for log/trace correlation and other features. Datadog recommends setting the following environment variables: +- `ENV PYTHONUNBUFFERED=1`: In your main container. Makes Python output appear immediately in container logs instead of being buffered. +- `ENV DD_LOGS_INJECTION=true`: In your main container. Enable log/trace correlation for supported loggers. +- `DD_SOURCE=python`: In your sidecar container. Enable advanced Datadog log parsing. + +Then, update your logging library. For example, you can use Python's native `logging` library: + +```python +LOG_FILE = "/LogFiles/app.log" +os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True) + +FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] ' + '[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] ' + '- %(message)s') + +logging.basicConfig( + level=logging.INFO, + format=FORMAT, + handlers=[ + logging.FileHandler(LOG_FILE), + logging.StreamHandler(sys.stdout) + ] +) +logger = logging.getLogger(__name__) +logger.level = logging.INFO + +logger.info('Hello world!') +``` + +For more information, see [Correlating Python Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/python/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=python#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=python#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% step title="Enable profiling (preview)" %} +To enable the [Continuous Profiler](/profiler/), set the environment variable `DD_PROFILING_ENABLED=true` in your application container. + +{% alert %} +Datadog's Continuous Profiler is available in preview for Azure Container Apps. +{% /alert %} +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "node_js") %} +{% stepper %} +{% step title="Install the Datadog Node.js SDK" %} +In your main application, install the `dd-trace` package. + +```shell +npm install dd-trace +``` + +Initialize the Node.js tracer with the `NODE_OPTIONS` environment variable: + +```dockerfile {% filename="Dockerfile" %} +ENV NODE_OPTIONS="--require dd-trace/init" +``` + +For more information, see [Tracing Node.js applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/). +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. In Node.js, Datadog recommends writing logs in a JSON format. For example, you can use a third-party logging library such as `winston`: + +```javascript +const { createLogger, format, transports } = require('winston'); + +const LOG_FILE = "/LogFiles/app.log" + +const logger = createLogger({ + level: 'info', + exitOnError: false, + format: format.json(), + transports: [ + new transports.File({ filename: LOG_FILE }), + new transports.Console() + ], +}); + +logger.info('Hello world!'); +``` + +Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=nodejs` (in your sidecar container) to enable advanced Datadog log parsing. + +For more information, see [Correlating Node.js Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/nodejs/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% step title="Enable profiling (preview)" %} +To enable the [Continuous Profiler](/profiler/), set the environment variable `DD_PROFILING_ENABLED=true` in your application container. + +{% alert %} +Datadog's Continuous Profiler is available in preview for Azure Container Apps. +{% /alert %} +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "go") %} +{% stepper %} +{% step title="Install the Datadog Go SDK" %} +In your main application, add the SDK from `dd-trace-go`. + +```shell +go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer +``` + +Add the following to your application code to initialize the tracer: + +```go +tracer.Start() +defer tracer.Stop() +``` + +You can also add additional packages: + +```shell +# Enable Profiling +go get github.com/DataDog/dd-trace-go/v2/profiler + +# Patch /net/http +go get github.com/DataDog/dd-trace-go/contrib/net/http/v2 +``` + +For more information, see [Tracing Go Applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/) and the [Tracer README](https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#installing). +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. In Go, Datadog recommends writing logs in a JSON format. For example, you can use a third-party logging library such as `logrus`: + +```go +const LOG_FILE = "/LogFiles/app.log" + +os.MkdirAll(filepath.Dir(LOG_FILE), 0755) +logFile, err := os.OpenFile(LOG_FILE, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) +defer logFile.Close() + +logrus.SetOutput(logFile) +logrus.SetFormatter(&logrus.JSONFormatter{}) +logrus.AddHook(&dd_logrus.DDContextLogHook{}) + +logrus.WithContext(ctx).Info("Hello World!") +``` + +Datadog recommends setting the environment variable `DD_SOURCE=go` in your sidecar container to enable advanced Datadog log parsing. + +For more information, see [Correlating Go Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/go/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=go#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=go#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "java") %} +{% stepper %} +{% step title="Install the Datadog Java SDK" %} +Add the Datadog Java SDK to your Dockerfile: + +```dockerfile {% filename="Dockerfile" %} +ADD 'https://dtdg.co/latest-java-tracer' agent.jar +ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar" +``` + +Add the SDK artifacts. + +{% tabs %} +{% tab label="Maven" %} +```xml + + com.datadoghq + dd-trace-api + DD_TRACE_JAVA_VERSION_HERE + +``` +{% /tab %} +{% tab label="Gradle" %} +```groovy +implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' +``` +{% /tab %} +{% /tabs %} + +See [dd-trace-java releases](https://github.com/DataDog/dd-trace-java/releases) for the latest tracer version. + +Add the `@Trace` annotation to any method you want to trace. + +For more information, see [Tracing Java Applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/). +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. In Java, Datadog recommends writing logs in a JSON format. For example, you can use a third-party logging library such as `Log4j 2`: + +```java +private static final Logger logger = LogManager.getLogger(App.class); +logger.info("Hello World!"); +``` + +```xml {% filename="resources/log4j2.xml" %} + + + + + + + + + +``` + +Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=java` (in your sidecar container) to enable advanced Datadog log parsing. + +For more information, see [Correlating Java Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/java/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=java#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=java#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "dot_net") %} +{% stepper %} +{% step title="Install the Datadog .NET SDK" %} +Install the Datadog .NET SDK in your Dockerfile. + +{% tabs %} +{% tab label="Standard Linux (glibc)" %} +```dockerfile {% filename="Dockerfile" %} +ARG TRACER_VERSION +RUN curl -L -s "https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb" --output datadog-dotnet-apm.deb && \ + dpkg -i datadog-dotnet-apm.deb +``` +{% /tab %} +{% tab label="Alpine (musl)" %} +```dockerfile {% filename="Dockerfile" %} +# 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 +``` +{% /tab %} +{% /tabs %} + +See the [dd-trace-dotnet releases](https://github.com/DataDog/dd-trace-dotnet/releases/) to view the latest tracer version. + +For more information, see [Tracing .NET applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux). +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to that file set in `DD_SERVERLESS_LOG_PATH`. In .NET, Datadog recommends writing logs in a JSON format. For example, you can use a third-party logging library such as `Serilog`: + +```csharp +using Serilog; + +const string LOG_FILE = "/LogFiles/app.log"; + +builder.Host.UseSerilog((context, config) => +{ + // Ensure the directory exists + Directory.CreateDirectory(Path.GetDirectoryName(LOG_FILE)!); + + config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true)) + .WriteTo.File(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true), LOG_FILE); +}); + +logger.LogInformation("Hello World!"); +``` + +Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=csharp` (in your sidecar container) to enable advanced Datadog log parsing. + +For more information, see [Correlating .NET Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/dotnet/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=dotnet#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=dotnet#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "ruby") %} +{% stepper %} +{% step title="Install the Datadog Ruby SDK" %} +Add the `datadog` gem to your Gemfile: + +```ruby {% filename="Gemfile" %} +source 'https://rubygems.org' +gem 'datadog' +``` + +See [Tracing Ruby applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#instrument-your-application) for additional information on how to configure the SDK and enable auto instrumentation. +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. You can also set a custom format for log/trace correlation and other features. Datadog recommends setting the environment variable `DD_SOURCE=ruby` in your sidecar container to enable advanced Datadog log parsing. + +Then, update your logging library. For example, you can use Ruby's native `logger` library: + +```ruby +LOG_FILE = "/LogFiles/app.log" +FileUtils.mkdir_p(File.dirname(LOG_FILE)) + +logger = Logger.new(LOG_FILE) +logger.formatter = proc do |severity, datetime, progname, msg| + "[#{datetime}] #{severity}: [#{Datadog::Tracing.log_correlation}] #{msg}\n" +end + +logger.info "Hello World!" +``` + +For more information, see [Correlating Ruby Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/ruby/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=ruby#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=ruby#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + + +{% if equals($prog_lang, "php") %} +{% stepper %} +{% step title="Install the Datadog PHP SDK" %} +Install the Datadog PHP SDK in your Dockerfile. + +```dockerfile {% filename="Dockerfile" %} +RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ + && php datadog-setup.php --php-bin=all +``` + +When running the `datadog-setup.php` script, you can also enable Application Security and Profiling by using the `--enable-appsec` and `--enable-profiling` flags, respectively. + +If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: + +```shell +apk add libgcc +``` + +For more information, see [Tracing PHP applications](/tracing/trace_collection/automatic_instrumentation/dd_libraries/php/). +{% /step %} +{% step title="Install serverless-init as a sidecar" %} +{% partial file="serverless/aca-sidecar-install-methods.mdoc.md" /%} +{% /step %} +{% step title="Set up logs" %} +In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. For example: + +```php +const LOG_FILE = "/LogFiles/app.log"; + +function logInfo($message) { + Log::build([ + 'driver' => 'single', + 'path' => LOG_FILE, + ])->info($message); +} + +logInfo('Hello World!'); +``` + +Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=php` (in your sidecar container) to enable advanced Datadog log parsing. + +For more information, see [Correlating PHP Logs and Traces](/tracing/other_telemetry/connect_logs_and_traces/php/). +{% /step %} +{% step title="Send custom metrics" %} +To send custom metrics, [install the DogStatsD client](/extend/dogstatsd/?tab=php#install-the-dogstatsd-client) and [view code examples](/metrics/custom_metrics/dogstatsd_metrics_submission/?tab=php#code-examples-5). In serverless, only the *distribution* metric type is supported. +{% /step %} +{% /stepper %} +{% /if %} + + +{% /if %} + + +## Environment variables {% #environment-variables %} + + +{% if equals($instrumentation_method, "in_container") %} +{% partial file="serverless/serverless-init-env-vars-in-container.mdoc.md" /%} +{% /if %} + + +{% if equals($instrumentation_method, "sidecar") %} +{% partial file="serverless/serverless-init-env-vars-sidecar.mdoc.md" /%} +{% /if %} + +{% partial file="serverless/svl-tracing-env.mdoc.md" /%} + +## Troubleshooting + +{% partial file="serverless/serverless-init-troubleshooting.mdoc.md" /%} diff --git a/content/en/serverless/azure_container_apps/in_container/_index.md b/content/en/serverless/azure_container_apps/in_container/_index.md deleted file mode 100644 index 111ef4c05a8..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/_index.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: In-Container Instrumentation -type: multi-code-lang -aliases: - - /serverless/guide/aca_serverless_init/ ---- - -First, set up the **[Azure Integration][1]** to collect metrics and logs from Azure Container Apps. - -Then, instrument your application using one of the following guides: - -{{% container-languages path="azure_container_apps/in_container" %}} - -[1]: /integrations/azure diff --git a/content/en/serverless/azure_container_apps/in_container/dotnet.md b/content/en/serverless/azure_container_apps/in_container/dotnet.md deleted file mode 100644 index c2e22552a5a..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/dotnet.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: Instrumenting a .NET Container App In-Container -code_lang: dotnet -type: multi-code-lang -code_lang_weight: 50 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux' - tag: 'Documentation' - text: 'Tracing .NET Core Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/dotnet/' - tag: 'Documentation' - text: 'Correlating .NET Logs and Traces' ---- - -## Setup - -1. **Install the Datadog .NET SDK** in your Dockerfile. - - Because GitHub requests are rate limited, you must pass a GitHub token saved in the environment variable `GITHUB_TOKEN` as a [Docker build secret][1] `--secret id=github-token,env=GITHUB_TOKEN`. - - {{< tabs >}} - {{% tab "Standard Linux (glibc)" %}} -{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \ - chmod +x /app/dotnet.sh && /app/dotnet.sh -{{< /code-block >}} - {{% /tab %}} - - {{% tab "Alpine (musl)" %}} -{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -# 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 -{{< /code-block >}} - {{% /tab %}} - {{< /tabs >}} - - For more information, see [Tracing .NET applications][2]. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="\"dotnet\", \"dotnet.dll\"" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends setting the environment variables `DD_LOGS_INJECTION=true` and `DD_SOURCE=csharp` to enable advanced Datadog log parsing. - - If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `Serilog`: - - {{< code-block lang="csharp" disable_copy="false" >}} -using Serilog; - -builder.Host.UseSerilog((context, config) => -{ - config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true)); -}); - -logger.LogInformation("Hello World!"); -{{< /code-block >}} - - For more information, see [Correlating .NET Logs and Traces][3]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -5. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-in-container language="csharp" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://docs.docker.com/build/building/secrets/ -[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux -[3]: /tracing/other_telemetry/connect_logs_and_traces/dotnet/ -[4]: /extend/dogstatsd/?tab=dotnet#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=dotnet#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/in_container/go.md b/content/en/serverless/azure_container_apps/in_container/go.md deleted file mode 100644 index 39dc052b14d..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/go.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: Instrumenting a Go Container App In-Container -code_lang: go -type: multi-code-lang -code_lang_weight: 30 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/' - tag: 'Documentation' - text: 'Tracing Go Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/go/' - tag: 'Documentation' - text: 'Correlating Go Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Go SDK**. - - 1. In your main application, add the SDK from `dd-trace-go`. - - {{< code-block lang="shell" disable_copy="false" >}} -go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer -{{< /code-block >}} - - 2. Add the following to your application code to initialize the tracer: - {{< code-block lang="go" disable_copy="false" >}} -tracer.Start() -defer tracer.Stop() -{{< /code-block >}} - - You can also add additional packages: - {{< code-block lang="shell" disable_copy="false" >}} -# Enable Profiling -go get github.com/DataDog/dd-trace-go/v2/profiler - -# Patch /net/http -go get github.com/DataDog/dd-trace-go/contrib/net/http/v2 -{{< /code-block >}} - - For more information, see [Tracing Go Applications][1] and the [Tracer README][2]. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="./your-binary" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends setting the environment variable `DD_SOURCE=go` to enable advanced Datadog log parsing. - - If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `logrus`: - ```go - logrus.SetFormatter(&logrus.JSONFormatter{}) - logrus.AddHook(&dd_logrus.DDContextLogHook{}) - - logrus.WithContext(ctx).Info("Hello World!") - ``` - - For more information, see [Correlating Go Logs and Traces][3]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -6. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-in-container language="go" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go/ -[2]: https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#installing -[3]: /tracing/other_telemetry/connect_logs_and_traces/go/ -[4]: /extend/dogstatsd/?tab=go#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=go#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/in_container/java.md b/content/en/serverless/azure_container_apps/in_container/java.md deleted file mode 100644 index 11fd7f09a13..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/java.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: Instrumenting a Java Container App In-Container -code_lang: java -type: multi-code-lang -code_lang_weight: 40 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/' - tag: 'Documentation' - text: 'Tracing Java Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/java/' - tag: 'Documentation' - text: 'Correlating Java Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Java SDK**. - - 1. Add the Datadog Java SDK to your Dockerfile: - - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -ADD 'https://dtdg.co/latest-java-tracer' agent.jar -ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar" -{{< /code-block >}} - - 2. Add the SDK artifacts. - {{< tabs >}} - {{% tab "Maven" %}} -{{< code-block lang="xml" disable_copy="false" >}} - - com.datadoghq - dd-trace-api - DD_TRACE_JAVA_VERSION_HERE - -{{< /code-block >}} - {{% /tab %}} - - {{% tab "Gradle" %}} -{{< code-block lang="groovy" disable_copy="false" >}} -implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' -{{< /code-block >}} - {{% /tab %}} - {{< /tabs >}} - - See [dd-trace-java releases][1] for the latest tracer version. - - 3. Add the `@Trace` annotation to any method you want to trace. - - For more information, see [Tracing Java Applications][2]. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="\"./mvnw\", \"spring-boot:run\"" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends setting the environment variable `DD_LOGS_INJECTION=true` and `DD_SOURCE=java` to enable advanced Datadog log parsing. - - If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in *compact* JSON format. For example, you can use a third-party logging library such as `Log4j 2`: - - {{< code-block lang="java" disable_copy="false" >}} -private static final Logger logger = LogManager.getLogger(App.class); -logger.info("Hello World!"); -{{< /code-block >}} - - {{< code-block lang="xml" filename="resources/log4j2.xml" disable_copy="false" >}} - - - - - - -{{< /code-block >}} - - For more information, see [Correlating Java Logs and Traces][3]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -5. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-in-container language="java" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://github.com/DataDog/dd-trace-java/releases -[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/java/ -[3]: /tracing/other_telemetry/connect_logs_and_traces/java/ -[4]: /extend/dogstatsd/?tab=java#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=java#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/in_container/nodejs.md b/content/en/serverless/azure_container_apps/in_container/nodejs.md deleted file mode 100644 index 28a8dd9f250..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/nodejs.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: Instrumenting a Node.js Container App In-Container -code_lang: nodejs -type: multi-code-lang -code_lang_weight: 20 -further_reading: -- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/' - tag: 'Documentation' - text: 'Tracing Node.js Applications' -- link: '/tracing/other_telemetry/connect_logs_and_traces/nodejs/' - tag: 'Documentation' - text: 'Correlating Node.js Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Node.js SDK**. - - 1. In your main application, install the `dd-trace` package. - - {{< code-block lang="shell" disable_copy="false" >}} -npm install dd-trace -{{< /code-block >}} - - 2. Initialize the Node.js tracer with the `NODE_OPTIONS` environment variable: - {{< code-block lang="dockerfile" disable_copy="false" >}} -ENV NODE_OPTIONS="--require dd-trace/init" -{{< /code-block >}} - - For more information, see [Tracing Node.js applications][1]. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="\"/nodejs/bin/node\", \"/path/to/your/app.js\"" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends setting the environment variable `DD_LOGS_INJECTION=true` and `DD_SOURCE=nodejs` to enable advanced Datadog log parsing. - - If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `winston`: - {{< code-block lang="javascript" disable_copy="false" >}} -const { createLogger, format, transports } = require('winston'); - -const logger = createLogger({ - level: 'info', - exitOnError: false, - format: format.json(), - transports: [ - new transports.Console() - ], -}); - -logger.info('Hello world!'); -{{< /code-block >}} - - For more information, see [Correlating Node.js Logs and Traces][2]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -5. **Send custom metrics**. - - To send custom metrics, [view code examples][3]. In serverless, only the *distribution* metric type is supported. - -6. **Enable profiling (preview)**. - - To enable the [Continuous Profiler][4], set the environment variable `DD_PROFILING_ENABLED=true`. - -
Datadog's Continuous Profiler is available in preview for Azure Container Apps.
- -{{% serverless-init-env-vars-in-container language="nodejs" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ -[2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ -[3]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5 -[4]: /profiler/ diff --git a/content/en/serverless/azure_container_apps/in_container/php.md b/content/en/serverless/azure_container_apps/in_container/php.md deleted file mode 100644 index dc2faa91584..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/php.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: Instrumenting a PHP Container App In-Container -code_lang: php -type: multi-code-lang -code_lang_weight: 70 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/php/' - tag: 'Documentation' - text: 'Tracing PHP Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/php/' - tag: 'Documentation' - text: 'Correlating PHP Logs and Traces' ---- - -## Setup - -1. **Install the Datadog PHP SDK** in your Dockerfile. - - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ - && php datadog-setup.php --php-bin=all -{{< /code-block >}} - - When running the `datadog-setup.php` script, you can also enable Application Security and Profiling by using the `--enable-appsec` and `--enable-profiling` flags, respectively. - - If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: - - {{< code-block lang="shell" disable_copy="false" >}} -apk add libgcc -{{< /code-block >}} - - For more information, see [Tracing PHP applications][1]. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="\"apache2-foreground\"" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends setting the environment variable `DD_LOGS_INJECTION=true` and `DD_SOURCE=php` to enable advanced Datadog log parsing. - - For more information, see [Correlating PHP Logs and Traces][2]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -5. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][3] and [view code examples][4]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-in-container language="php" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/php/ -[2]: /tracing/other_telemetry/connect_logs_and_traces/php/ -[3]: /extend/dogstatsd/?tab=php#install-the-dogstatsd-client -[4]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=php#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/in_container/python.md b/content/en/serverless/azure_container_apps/in_container/python.md deleted file mode 100644 index 1505f0e534c..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/python.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: Instrumenting a Python Container App In-Container -code_lang: python -type: multi-code-lang -code_lang_weight: 10 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/python/' - tag: 'Documentation' - text: 'Tracing Python Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/python/' - tag: 'Documentation' - text: 'Correlating Python Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Python SDK**. - - Add `ddtrace` to your `requirements.txt` or `pyproject.toml`. You can find the latest version on [PyPI][1]: - {{< code-block lang="text" filename="requirements.txt" disable_copy="false" collapsible="true" >}} -ddtrace== -{{< /code-block >}} - - Alternatively, you can install the SDK in your Dockerfile: - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -RUN pip install ddtrace -{{< /code-block >}} - - Then, wrap your start command with `ddtrace-run`: - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -CMD ["ddtrace-run", "python", "app.py"] -{{< /code-block >}} - - For more information, see [Tracing Python applications][2]. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="\"ddtrace-run\", \"python\", \"path/to/your/python/app.py\"" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends the following environment variables: - - `ENV PYTHONUNBUFFERED=1`: Ensure Python outputs appear immediately in container logs instead of being buffered. - - `ENV DD_LOGS_INJECTION=true`: Enable log/trace correlation for supported loggers. - - `ENV DD_SOURCE=python`: Enable advanced Datadog log parsing. - - If you want multiline logs to be preserved in a single log message, Datadog recommends writing your logs in JSON format. For example, you can use a third-party logging library such as `structlog`: - {{< code-block lang="python" disable_copy="false" >}} -import structlog - -def tracer_injection(logger, log_method, event_dict): - event_dict.update(tracer.get_log_correlation_context()) - return event_dict - -structlog.configure( - processors=[ - tracer_injection, - structlog.processors.EventRenamer("msg"), - structlog.processors.JSONRenderer() - ], - logger_factory=structlog.WriteLoggerFactory(file=sys.stdout), -) - -logger = structlog.get_logger() - -logger.info("Hello world!") -{{< /code-block >}} - - For more information, see [Correlating Python Logs and Traces][3]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -5. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -6. **Enable profiling (preview)**. - - To enable the [Continuous Profiler][6], set the environment variable `DD_PROFILING_ENABLED=true`. - -
Datadog's Continuous Profiler is available in preview for Azure Container Apps.
- -{{% serverless-init-env-vars-in-container language="python" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://pypi.org/project/ddtrace/ -[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/python -[3]: /tracing/other_telemetry/connect_logs_and_traces/python/ -[4]: /extend/dogstatsd/?tab=python#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=python#code-examples-5 -[6]: /profiler/ diff --git a/content/en/serverless/azure_container_apps/in_container/ruby.md b/content/en/serverless/azure_container_apps/in_container/ruby.md deleted file mode 100644 index af2f8c519ea..00000000000 --- a/content/en/serverless/azure_container_apps/in_container/ruby.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -title: Instrumenting a Ruby Container App In-Container -code_lang: ruby -type: multi-code-lang -code_lang_weight: 60 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/' - tag: 'Documentation' - text: 'Tracing Ruby Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/ruby/' - tag: 'Documentation' - text: 'Correlating Ruby Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Ruby SDK**. - - Add the `datadog` gem to your Gemfile: - {{< code-block lang="gemfile" disable_copy="false" >}} -source 'https://rubygems.org' -gem 'datadog' -{{< /code-block >}} - - See [Tracing Ruby applications][1] for additional information on how to configure the SDK and enable auto instrumentation. - -2. **Install serverless-init**. - - {{% serverless-init-install mode="in-container" cmd="\"rails\", \"server\", \"-b\", \"0.0.0.0\"" %}} - -3. **Set up logs**. - - To enable logging, set the environment variable `DD_LOGS_ENABLED=true`. This allows `serverless-init` to read logs from stdout and stderr. - - Datadog also recommends setting the environment variable `DD_SOURCE=ruby` to enable advanced Datadog log parsing. - - To enable log-trace correlation, you need to include `Datadog::Tracing.log_correlation` in your log format. For example: - {{< code-block lang="ruby" disable_copy="false" >}} -logger = Logger.new(STDOUT) -logger.formatter = proc do |severity, datetime, progname, msg| - "[#{datetime}] #{severity}: [#{Datadog::Tracing.log_correlation}] #{msg}\n" -end - -logger.info "Hello world!" -{{< /code-block >}} - - For more information, see [Correlating Ruby Logs and Traces][2]. - -4. **Configure your application**. - -{{% serverless-init-configure %}} - -5. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][3] and [view code examples][4]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-in-container language="ruby" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#instrument-your-application -[2]: /tracing/other_telemetry/connect_logs_and_traces/ruby/ -[3]: /extend/dogstatsd/?tab=ruby#install-the-dogstatsd-client -[4]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=ruby#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/sidecar/_index.md b/content/en/serverless/azure_container_apps/sidecar/_index.md deleted file mode 100644 index cd8a27ffca6..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/_index.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: Sidecar Instrumentation -type: multi-code-lang ---- - -First, set up the **[Azure Integration][1]** to collect metrics and logs from Azure Container Apps. - -Then, instrument your application using one of the following guides: - -{{% container-languages path="azure_container_apps/sidecar" %}} - -[1]: /integrations/azure diff --git a/content/en/serverless/azure_container_apps/sidecar/dotnet.md b/content/en/serverless/azure_container_apps/sidecar/dotnet.md deleted file mode 100644 index d78e76fca06..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/dotnet.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: Instrumenting a .NET Container App with Sidecar -code_lang: dotnet -type: multi-code-lang -code_lang_weight: 50 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux' - tag: 'Documentation' - text: 'Tracing .NET Core Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/dotnet/' - tag: 'Documentation' - text: 'Correlating .NET Logs and Traces' ---- - -## Setup - -1. **Install the Datadog .NET SDK** in your Dockerfile. - - {{< tabs >}} - {{% tab "Standard Linux (glibc)" %}} -{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -ARG TRACER_VERSION -RUN curl -L -s "https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb" --output datadog-dotnet-apm.deb && \ - dpkg -i datadog-dotnet-apm.deb -{{< /code-block >}} - {{% /tab %}} - - {{% tab "Alpine (musl)" %}} -{{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -# 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 -{{< /code-block >}} - {{% /tab %}} - {{< /tabs >}} - - See the [dd-trace-dotnet releases][1] to view the latest tracer version. - - For more information, see [Tracing .NET applications][2]. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to that file set in `DD_SERVERLESS_LOG_PATH`. In .NET, we recommend writing logs in a JSON format. For example, you can use a third-party logging library such as `Serilog`: - {{< code-block lang="csharp" disable_copy="false" >}} -using Serilog; - -const string LOG_FILE = "/LogFiles/app.log"; - -builder.Host.UseSerilog((context, config) => -{ - // Ensure the directory exists - Directory.CreateDirectory(Path.GetDirectoryName(LOG_FILE)!); - - config.WriteTo.Console(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true)) - .WriteTo.File(new Serilog.Formatting.Json.JsonFormatter(renderMessage: true), LOG_FILE); -}); - -logger.LogInformation("Hello World!"); -{{< /code-block >}} - - Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=csharp` (in your sidecar container) to enable advanced Datadog log parsing. - - For more information, see [Correlating .NET Logs and Traces][3]. - -4. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-sidecar language="csharp" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://github.com/DataDog/dd-trace-dotnet/releases/ -[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux -[3]: /tracing/other_telemetry/connect_logs_and_traces/dotnet/ -[4]: /extend/dogstatsd/?tab=dotnet#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=dotnet#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/sidecar/go.md b/content/en/serverless/azure_container_apps/sidecar/go.md deleted file mode 100644 index d7b3f05f059..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/go.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: Instrumenting a Go Container App with Sidecar -code_lang: go -type: multi-code-lang -code_lang_weight: 30 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/go/' - tag: 'Documentation' - text: 'Tracing Go Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/go/' - tag: 'Documentation' - text: 'Correlating Go Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Go SDK**. - - 1. In your main application, add the SDK from `dd-trace-go`. - - {{< code-block lang="shell" disable_copy="false" >}} -go get github.com/DataDog/dd-trace-go/v2/ddtrace/tracer -{{< /code-block >}} - - 2. Add the following to your application code to initialize the tracer: - {{< code-block lang="go" disable_copy="false" >}} -tracer.Start() -defer tracer.Stop() -{{< /code-block >}} - - You can also add additional packages: - {{< code-block lang="shell" disable_copy="false" >}} -# Enable Profiling -go get github.com/DataDog/dd-trace-go/v2/profiler - -# Patch /net/http -go get github.com/DataDog/dd-trace-go/contrib/net/http/v2 -{{< /code-block >}} - - For more information, see [Tracing Go Applications][1] and the [Tracer README][2]. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. In Go, we recommend writing logs in a JSON format. For example, you can use a third-party logging library such as `logrus`: - {{< code-block lang="go" disable_copy="false" >}} -const LOG_FILE = "/LogFiles/app.log" - -os.MkdirAll(filepath.Dir(LOG_FILE), 0755) -logFile, err := os.OpenFile(LOG_FILE, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) -defer logFile.Close() - -logrus.SetOutput(logFile) -logrus.SetFormatter(&logrus.JSONFormatter{}) -logrus.AddHook(&dd_logrus.DDContextLogHook{}) - -logrus.WithContext(ctx).Info("Hello World!") -{{< /code-block >}} - - Datadog recommends setting the environment variable `DD_SOURCE=go` in your sidecar container to enable advanced Datadog log parsing. - - For more information, see [Correlating Go Logs and Traces][3]. - -4. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-sidecar language="go" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go/ -[2]: https://github.com/DataDog/dd-trace-go?tab=readme-ov-file#installing -[3]: /tracing/other_telemetry/connect_logs_and_traces/go/ -[4]: /extend/dogstatsd/?tab=go#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=go#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/sidecar/java.md b/content/en/serverless/azure_container_apps/sidecar/java.md deleted file mode 100644 index 83e2b2dba45..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/java.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -title: Instrumenting a Java Container App with Sidecar -code_lang: java -type: multi-code-lang -code_lang_weight: 40 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/' - tag: 'Documentation' - text: 'Tracing Java Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/java/' - tag: 'Documentation' - text: 'Correlating Java Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Java SDK**. - - 1. Add the Datadog Java SDK to your Dockerfile: - - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -ADD 'https://dtdg.co/latest-java-tracer' agent.jar -ENV JAVA_TOOL_OPTIONS="-javaagent:agent.jar" -{{< /code-block >}} - - 2. Add the SDK artifacts. - {{< tabs >}} - {{% tab "Maven" %}} -{{< code-block lang="xml" disable_copy="false" >}} - - com.datadoghq - dd-trace-api - DD_TRACE_JAVA_VERSION_HERE - -{{< /code-block >}} - {{% /tab %}} - - {{% tab "Gradle" %}} -{{< code-block lang="groovy" disable_copy="false" >}} -implementation 'com.datadoghq:dd-trace-api:DD_TRACE_JAVA_VERSION_HERE' -{{< /code-block >}} - {{% /tab %}} - {{< /tabs >}} - - See [dd-trace-java releases][1] for the latest tracer version. - - 3. Add the `@Trace` annotation to any method you want to trace. - - For more information, see [Tracing Java Applications][2]. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. In Java, we recommend writing logs in a JSON format. For example, you can use a third-party logging library such as `Log4j 2`: - - {{< code-block lang="java" disable_copy="false" >}} -private static final Logger logger = LogManager.getLogger(App.class); -logger.info("Hello World!"); -{{< /code-block >}} - - {{< code-block lang="xml" filename="resources/log4j2.xml" disable_copy="false" >}} - - - - - - - - - -{{< /code-block >}} - - Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=java` (in your sidecar container) to enable advanced Datadog log parsing. - - For more information, see [Correlating Java Logs and Traces][3]. - -4. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-sidecar language="java" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://github.com/DataDog/dd-trace-java/releases -[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/java/ -[3]: /tracing/other_telemetry/connect_logs_and_traces/java/ -[4]: /extend/dogstatsd/?tab=java#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=java#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/sidecar/nodejs.md b/content/en/serverless/azure_container_apps/sidecar/nodejs.md deleted file mode 100644 index baa9a5cbaeb..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/nodejs.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: Instrumenting a Node.js Container App with Sidecar -code_lang: nodejs -type: multi-code-lang -code_lang_weight: 20 -further_reading: -- link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/' - tag: 'Documentation' - text: 'Tracing Node.js Applications' -- link: '/tracing/other_telemetry/connect_logs_and_traces/nodejs/' - tag: 'Documentation' - text: 'Correlating Node.js Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Node.js SDK**. - - 1. In your main application, install the `dd-trace` package. - - {{< code-block lang="shell" disable_copy="false" >}} -npm install dd-trace -{{< /code-block >}} - - 2. Initialize the Node.js tracer with the `NODE_OPTIONS` environment variable: - {{< code-block lang="dockerfile" disable_copy="false" >}} -ENV NODE_OPTIONS="--require dd-trace/init" -{{< /code-block >}} - - For more information, see [Tracing Node.js applications][1]. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. In Node.js, we recommend writing logs in a JSON format. For example, you can use a third-party logging library such as `winston`: - {{< code-block lang="javascript" disable_copy="false" >}} -const { createLogger, format, transports } = require('winston'); - -const LOG_FILE = "/LogFiles/app.log" - -const logger = createLogger({ - level: 'info', - exitOnError: false, - format: format.json(), - transports: [ - new transports.File({ filename: LOG_FILE }), - new transports.Console() - ], -}); - -logger.info('Hello world!'); -{{< /code-block >}} - - Datadog recommends setting the environment variables `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=nodejs` (in your sidecar container) to enable advanced Datadog log parsing. - - For more information, see [Correlating Node.js Logs and Traces][2]. - -4. **Send custom metrics**. - - To send custom metrics, [view code examples][3]. In serverless, only the *distribution* metric type is supported. - -5. **Enable profiling (preview)**. - - To enable the [Continuous Profiler][4], set the environment variable `DD_PROFILING_ENABLED=true` in your application container. - -
Datadog's Continuous Profiler is available in preview for Azure Container Apps.
- -{{% serverless-init-env-vars-sidecar language="nodejs" defaultSource="cloudrun" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Cloud Run services" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/ -[2]: /tracing/other_telemetry/connect_logs_and_traces/nodejs/ -[3]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=nodejs#code-examples-5 -[4]: /profiler/ diff --git a/content/en/serverless/azure_container_apps/sidecar/php.md b/content/en/serverless/azure_container_apps/sidecar/php.md deleted file mode 100644 index c4627af6b54..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/php.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: Instrumenting a PHP Container App with Sidecar -code_lang: php -type: multi-code-lang -code_lang_weight: 70 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/php/' - tag: 'Documentation' - text: 'Tracing PHP Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/php/' - tag: 'Documentation' - text: 'Correlating PHP Logs and Traces' ---- - -## Setup - -1. **Install the Datadog PHP SDK** in your Dockerfile. - - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php \ - && php datadog-setup.php --php-bin=all -{{< /code-block >}} - - When running the `datadog-setup.php` script, you can also enable Application Security and Profiling by using the `--enable-appsec` and `--enable-profiling` flags, respectively. - - If you are using Alpine Linux, you need to install `libgcc_s` prior to running the installer: - - {{< code-block lang="shell" disable_copy="false" >}} -apk add libgcc -{{< /code-block >}} - - For more information, see [Tracing PHP applications][1]. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. For example: - - {{< code-block lang="php" disable_copy="false" >}} -const LOG_FILE = "/LogFiles/app.log"; - -function logInfo($message) { - Log::build([ - 'driver' => 'single', - 'path' => LOG_FILE, - ])->info($message); -} - -logInfo('Hello World!'); -{{< /code-block >}} - - Datadog recommends setting the environment variable `DD_LOGS_INJECTION=true` (in your main container) and `DD_SOURCE=php` (in your sidecar container) to enable advanced Datadog log parsing. - - For more information, see [Correlating PHP Logs and Traces][2]. - -4. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][3] and [view code examples][4]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-sidecar language="php" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/php/ -[2]: /tracing/other_telemetry/connect_logs_and_traces/php/ -[3]: /extend/dogstatsd/?tab=php#install-the-dogstatsd-client -[4]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=php#code-examples-5 diff --git a/content/en/serverless/azure_container_apps/sidecar/python.md b/content/en/serverless/azure_container_apps/sidecar/python.md deleted file mode 100644 index f218124f572..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/python.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: Instrumenting a Python Container App with Sidecar -code_lang: python -type: multi-code-lang -code_lang_weight: 10 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/python/' - tag: 'Documentation' - text: 'Tracing Python Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/python/' - tag: 'Documentation' - text: 'Correlating Python Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Python SDK**. - - Add `ddtrace` to your `requirements.txt` or `pyproject.toml`. You can find the latest version on [PyPI][1]: - {{< code-block lang="text" filename="requirements.txt" disable_copy="false" collapsible="true" >}} -ddtrace== -{{< /code-block >}} - - Alternatively, you can install the SDK in your Dockerfile: - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -RUN pip install ddtrace -{{< /code-block >}} - - Then, wrap your start command with `ddtrace-run`: - {{< code-block lang="dockerfile" filename="Dockerfile" disable_copy="false" collapsible="true" >}} -CMD ["ddtrace-run", "python", "app.py"] -{{< /code-block >}} - - For more information, see [Tracing Python applications][2]. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. You can also set a custom format for log/trace correlation and other features. Datadog recommends setting the following environment variables: - - `ENV PYTHONUNBUFFERED=1`: In your main container. Ensure Python outputs appear immediately in container logs instead of being buffered. - - `ENV DD_LOGS_INJECTION=true`: In your main container. Enable log/trace correlation for supported loggers. - - `DD_SOURCE=python`: In your sidecar container. Enable advanced Datadog log parsing. - - Then, update your logging library. For example, you can use Python's native `logging` library: - {{< code-block lang="python" disable_copy="false" >}} -LOG_FILE = "/LogFiles/app.log" -os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True) - -FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] ' - '[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] ' - '- %(message)s') - -logging.basicConfig( - level=logging.INFO, - format=FORMAT, - handlers=[ - logging.FileHandler(LOG_FILE), - logging.StreamHandler(sys.stdout) - ] -) -logger = logging.getLogger(__name__) -logger.level = logging.INFO - -logger.info('Hello world!') -{{< /code-block >}} - - For more information, see [Correlating Python Logs and Traces][3]. - -4. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][4] and [view code examples][5]. In serverless, only the *distribution* metric type is supported. - -5. **Enable profiling (preview)**. - - To enable the [Continuous Profiler][6], set the environment variable `DD_PROFILING_ENABLED=true` in your application container. - -
Datadog's Continuous Profiler is available in preview for Azure Container Apps.
- -{{% serverless-init-env-vars-sidecar language="python" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: https://pypi.org/project/ddtrace/ -[2]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/python -[3]: /tracing/other_telemetry/connect_logs_and_traces/python/ -[4]: /extend/dogstatsd/?tab=python#install-the-dogstatsd-client -[5]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=python#code-examples-5 -[6]: /profiler/ diff --git a/content/en/serverless/azure_container_apps/sidecar/ruby.md b/content/en/serverless/azure_container_apps/sidecar/ruby.md deleted file mode 100644 index af72c84fa02..00000000000 --- a/content/en/serverless/azure_container_apps/sidecar/ruby.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Instrumenting a Ruby Container App with Sidecar -code_lang: ruby -type: multi-code-lang -code_lang_weight: 60 -further_reading: - - link: '/tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/' - tag: 'Documentation' - text: 'Tracing Ruby Applications' - - link: '/tracing/other_telemetry/connect_logs_and_traces/ruby/' - tag: 'Documentation' - text: 'Correlating Ruby Logs and Traces' ---- - -## Setup - -1. **Install the Datadog Ruby SDK**. - - Add the `datadog` gem to your Gemfile: - {{< code-block lang="gemfile" disable_copy="false" >}} -source 'https://rubygems.org' -gem 'datadog' -{{< /code-block >}} - - See [Tracing Ruby applications][1] for additional information on how to configure the SDK and enable auto instrumentation. - -2. **Install serverless-init as a sidecar**. - - {{% serverless-init-install mode="sidecar" %}} - - {{< tabs >}} - - {{% tab "Datadog CLI" %}} - {{% aca-install-sidecar-datadog-ci %}} - {{% /tab %}} - - {{% tab "Terraform" %}} - {{% aca-install-sidecar-terraform %}} - {{% /tab %}} - - {{% tab "Bicep" %}} - {{% aca-install-sidecar-bicep %}} - {{% /tab %}} - - {{% tab "ARM Template" %}} - {{% aca-install-sidecar-arm-template %}} - {{% /tab %}} - - {{% tab "Manual" %}} - {{% aca-install-sidecar-manual %}} - {{% /tab %}} - - {{< /tabs >}} - -3. **Set up logs**. - - In the previous step, you created a shared volume. In this step, configure your logging library to write logs to the file set in `DD_SERVERLESS_LOG_PATH`. You can also set a custom format for log/trace correlation and other features. Datadog recommends setting the environment variable `DD_SOURCE=ruby` in your sidecar container to enable advanced Datadog log parsing. - - Then, update your logging library. For example, you can use Ruby's native `logger` library: - {{< code-block lang="ruby" disable_copy="false" >}} -LOG_FILE = "/LogFiles/app.log" -FileUtils.mkdir_p(File.dirname(LOG_FILE)) - -logger = Logger.new(LOG_FILE) -logger.formatter = proc do |severity, datetime, progname, msg| - "[#{datetime}] #{severity}: [#{Datadog::Tracing.log_correlation}] #{msg}\n" -end - -logger.info "Hello World!" -{{< /code-block >}} - - For more information, see [Correlating Ruby Logs and Traces][2]. - -4. **Send custom metrics**. - - To send custom metrics, [install the DogStatsD client][3] and [view code examples][4]. In serverless, only the *distribution* metric type is supported. - -{{% serverless-init-env-vars-sidecar language="ruby" defaultSource="containerapp" %}} - -{{% svl-tracing-env %}} - -## Troubleshooting - -{{% serverless-init-troubleshooting productNames="Azure Container Apps" %}} - -## Further reading - -{{< partial name="whats-next/whats-next.html" >}} - -[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/ruby/#instrument-your-application -[2]: /tracing/other_telemetry/connect_logs_and_traces/ruby/ -[3]: /extend/dogstatsd/?tab=ruby#install-the-dogstatsd-client -[4]: /metrics/custom_metrics/dogstatsd_metrics_submission/?tab=ruby#code-examples-5 diff --git a/content/es/serverless/azure_container_apps/_index.md b/content/es/serverless/azure_container_apps/_index.md deleted file mode 100644 index 68f818fbdcc..00000000000 --- a/content/es/serverless/azure_container_apps/_index.md +++ /dev/null @@ -1,457 +0,0 @@ ---- -further_reading: -- link: https://www.datadoghq.com/blog/azure-container-apps/ - tag: Blog - text: Recopila trazas, logs y métricas personalizadas de servicios de Container - Apps -title: Azure Container Apps ---- - -
Para instrumentar tus aplicaciones Azure Container Apps con serverless-init, consulta Azure Container Apps con serverless-init3.
- -## Información general -Azure Container Apps 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 Container Apps a través de la [integración de Azure][1]. Datadog también brinda una solución para instrumentar las aplicaciones de Container Apps con un Agent especialmente diseñado para habilitar el rastreo, las métricas personalizadas y la recopilación directa de logs. - -## Configuración - -### Contenedor de aplicación - -{{< tabs >}} -{{% tab "Node.js" %}} -#### Rastreo -Instrumenta tu aplicación principal con la librería `dd-trace-js`. Para obtener instrucciones, consulta [Rastreo de aplicaciones Node.js][1]. - -#### Métricas -Las métricas personalizadas también se recopilan a través del rastreador. Consulta los [ejemplos de código][2]. - -#### Logs -El sidecar de Datadog utiliza el seguimiento de archivos para recopilar logs. - -En Azure, añade un volumen de montaje al contenedor auxiliar *y* a tus contenedores de aplicación utilizando el [almacenamiento de alcance de réplica][5]. Utiliza el tipo "Almacenamiento efímero" cuando crees tu volumen. Los ejemplos en esta página utilizan el nombre de volumen `logs` y la ruta de montaje `/LogFiles`. - -{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adición de un montaje de volumen a un contenedor en Azure" style="width:60%;" >}} - -Para configurar la generación de logs en tu aplicación, consulta [Recopilación de logs de Node.js][3]. Para configurar la correlación de logs de rastreo, consulta [Correlación de logs y trazas de Node.js][4]. - -[1]: /es/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started -[2]: /es/metrics/custom_metrics/dogstatsd_metrics_submission/#code-examples -[3]: /es/logs/log_collection/nodejs/?tab=winston30 -[4]: /es/tracing/other_telemetry/connect_logs_and_traces/nodejs -[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -{{% /tab %}} -{{% tab "Python" %}} -#### Rastreo -Instrumenta tu aplicación principal con la librería `dd-trace-py`. Para obtener instrucciones, consulta [Rastreo de aplicaciones Python][1]. - -#### Métricas -Las métricas personalizadas también se recopilan a través del rastreador. Consulta los [ejemplos de código][2]. - -#### Logs -El sidecar de Datadog utiliza el seguimiento de archivos para recopilar logs. - -En Azure, añade un volumen de montaje al contenedor auxiliar *y* a tus contenedores de aplicación utilizando el [almacenamiento de alcance de réplica][5]. Utiliza el tipo "Almacenamiento efímero" cuando crees tu volumen. Los ejemplos en esta página utilizan el nombre de volumen `logs` y la ruta de montaje `/LogFiles`. - -{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adición de un montaje de volumen a un contenedor en Azure" style="width:60%;" >}} - -Para configurar la generación de logs en tu aplicación, consulta [Recopilación de logs de Python][3]. Para configurar la correlación de logs de rastreo, consulta [Correlación de logs y trazas de Python][4]. - -[1]: /es/tracing/trace_collection/automatic_instrumentation/dd_libraries/python -[2]: /es/metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=python#code-examples -[3]: /es/logs/log_collection/python/ -[4]: /es/tracing/other_telemetry/connect_logs_and_traces/python -[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -{{% /tab %}} -{{% tab "Java" %}} -#### Rastreo -Instrumenta tu aplicación principal con la librería `dd-trace-java`. Para obtener instrucciones, consulta [Rastreo de aplicaciones Java][1]. - -#### Métricas -Las métricas personalizadas también se recopilan a través del rastreador. Consulta los [ejemplos de código][2]. - -#### Logs -El sidecar de Datadog utiliza el seguimiento de archivos para recopilar logs. - -En Azure, añade un volumen de montaje al contenedor auxiliar *y* a tus contenedores de aplicación utilizando el [almacenamiento de alcance de réplica][5]. Utiliza el tipo "Almacenamiento efímero" cuando crees tu volumen. Los ejemplos en esta página utilizan el nombre de volumen `logs` y la ruta de montaje `/LogFiles`. - -{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adición de un montaje de volumen a un contenedor en Azure" style="width:60%;" >}} - -Para configurar el registro en tu aplicación, consulta [Recopilación de logs de Java][3]. Para configurar la correlación de logs y trazas, consulta [Correlación de logs y trazas de Java][4]. - -[1]: /es/tracing/trace_collection/automatic_instrumentation/dd_libraries/java/#getting-started -[2]: /es/metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=java#code-examples -[3]: /es/logs/log_collection/java/?tab=winston30 -[4]: /es/tracing/other_telemetry/connect_logs_and_traces/java -[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -{{% /tab %}} -{{% tab "Go" %}} -#### Rastreo -Instrumenta tu aplicación principal con la librería `dd-trace-go`. Para obtener instrucciones, consulta [Rastreo de aplicaciones Go][1]. - -#### Métricas -Las métricas personalizadas también se recopilan a través del rastreador. Consulta los [ejemplos de código][2]. - -#### Logs -El sidecar de Datadog utiliza el seguimiento de archivos para recopilar logs. - -En Azure, añade un volumen de montaje al contenedor auxiliar *y* a tus contenedores de aplicación utilizando el [almacenamiento de alcance de réplica][5]. Utiliza el tipo "Almacenamiento efímero" cuando crees tu volumen. Los ejemplos en esta página utilizan el nombre de volumen `logs` y la ruta de montaje `/LogFiles`. - -{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adición de un montaje de volumen a un contenedor en Azure" style="width:60%;" >}} - -Para configurar la generación de logs en tu aplicación, consulta [Recopilación de logs de Go][3]. Para configurar la correlación de logs de rastreo, consulta [Correlación de logs y trazas de Go][4]. - -[1]: /es/tracing/trace_collection/automatic_instrumentation/dd_libraries/go -[2]: /es/metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=go#code-examples -[3]: /es/logs/log_collection/go/ -[4]: /es/tracing/other_telemetry/connect_logs_and_traces/go -[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -{{% /tab %}} -{{% tab ".NET" %}} -#### Rastreo -Instrumenta tu aplicación principal con la librería `dd-trace-dotnet`. Para obtener instrucciones, consulta [Rastreo de aplicaciones .NET][1]. - -#### Métricas -Las métricas personalizadas también se recopilan a través del rastreador. Consulta los [ejemplos de código][2]. - -#### Logs -El sidecar de Datadog utiliza el seguimiento de archivos para recopilar logs. - -En Azure, añade un volumen de montaje al contenedor auxiliar *y* a tus contenedores de aplicación utilizando el [almacenamiento de alcance de réplica][5]. Utiliza el tipo "Almacenamiento efímero" cuando crees tu volumen. Los ejemplos en esta página utilizan el nombre de volumen `logs` y la ruta de montaje `/LogFiles`. - -{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adición de un montaje de volumen a un contenedor en Azure" style="width:60%;" >}} - -Para configurar la generación de logs en tu aplicación, consulta [Recopilación de logs de .NET][3]. Para configurar la correlación de logs de rastreo, consulta [Correlación de logs y trazas de .NET][4]. - -[1]: /es/tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux -[2]: /es/metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=dotnet#code-examples -[3]: /es/logs/log_collection/csharp/ -[4]: /es/tracing/other_telemetry/connect_logs_and_traces/dotnet -[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -{{% /tab %}} -{{% tab "PHP" %}} -#### Rastreo -Instrumenta tu aplicación principal con la librería `dd-trace-php`. Para obtener instrucciones, consulta [Rastreo de aplicaciones PHP][1]. - -#### Métricas -Las métricas personalizadas también se recopilan a través del rastreador. Consulta los [ejemplos de código][2]. - -#### Logs -El sidecar de Datadog utiliza el seguimiento de archivos para recopilar logs. - -En Azure, añade un volumen de montaje al contenedor auxiliar *y* a tus contenedores de aplicación utilizando el [almacenamiento de alcance de réplica][5]. Utiliza el tipo "Almacenamiento efímero" cuando crees tu volumen. Los ejemplos en esta página utilizan el nombre de volumen `logs` y la ruta de montaje `/LogFiles`. - -{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adición de un montaje de volumen a un contenedor en Azure" style="width:60%;" >}} - -Para configurar la generación de logs en tu aplicación, consulta [Recopilación de logs de PHP][3]. Para configurar la correlación de logs de rastreo, consulta [Correlación de logs y trazas de PHP][4]. - -[1]: /es/tracing/trace_collection/automatic_instrumentation/dd_libraries/php/#getting-started -[2]: /es/metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=php#code-examples -[3]: /es/logs/log_collection/php/ -[4]: /es/tracing/other_telemetry/connect_logs_and_traces/php -[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -{{% /tab %}} -{{< /tabs >}} - -#### Variables de entorno -Dado que Azure Container Apps se basa en Kubernetes, no puedes compartir variables de entorno entre contenedores. Debes configurar variables de entorno de Datadog tanto en tu aplicación como en los contenedores de sidecars. - -| Nombre | Descripción | -| ---- | ----------- | -| `DD_SERVICE` | Cómo quieres etiquetar tu servicio. Por ejemplo, `sidecar-azure`. | -| `DD_ENV` | Cómo quieres etiquetar tu entorno. Por ejemplo, `prod`.| -| `DD_VERSION` | Cómo quieres etiquetar tu versión. | - -### Contenedor de sidecar -1. En el Portal Azure, ve a **Aplicación** > **Revisiones y réplicas**. Selecciona **Crear nueva revisión**. -2. En la pestaña **Contenedor**, bajo **Imagen de contenedor**, selecciona **Añadir** y luego selecciona **Contenedor de aplicación**. -3. En el formulario **Añadir un contenedor**, indica lo siguiente: - - **Nombre**: `datadog` - - **Fuente de la imagen**: Docker Hub u otros registros - - **Tipo de imagen**: `Public` - - **Servidor de inicio de sesión de registro**: `docker.io` - - **Imagen y etiqueta (tag)**: `datadog/serverless-init:latest` - - Define tu asignación de recursos de contenedor en función de tu uso. -4. Añade un volumen de montaje utilizando [almacenamiento de alcance de réplica][2]. Utiliza el tipo "Almacenamiento efímero" al crear el volumen. Asegúrate de que el nombre y la ruta de montaje coinciden con el montaje que configuraste en el contenedor de la aplicación. -5. Configura las variables de entorno de la siguiente tabla: - -#### Variables de entorno -| Nombre | Descripción | -| ---- | ----------- | -| `DD_AZURE_SUBSCRIPTION_ID` | **Requerido**. Tu ID de suscripción a Azure. | -| `DD_AZURE_RESOURCE_GROUP` | **Requerido**. Tu grupo de recursos Azure. | -| `DD_API_KEY` | **Requerido**. Tu [clave de API Datadog][3]. | -| `DD_SITE` | Tu sitio de Datadog: `{{< region-param key="dd_site" code="true" >}}` -| `DD_SERVICE` | Cómo quieres etiquetar tu servicio. Por ejemplo, `sidecar-azure`. | -| `DD_ENV` | Cómo quieres etiquetar tu entorno. Por ejemplo, `prod`.| -| `DD_VERSION` | Cómo quieres etiquetar tu versión. | -| `DD_SERVERLESS_LOG_PATH` | Dónde escribes tus logs. Por ejemplo, `/LogFiles/*.log`. | - -### Ejemplo de aplicación - -En los siguientes ejemplos, imagina que configuras la ruta de montaje en `/LogFiles` y que escribes logs en `/LogFiles/app.log`. - -{{< tabs >}} -{{% tab "Node.js" %}} - -```js -const tracer = require('dd-trace').init({ - logInjection: true, -}); -const express = require("express"); -const app = express(); -const { createLogger, format, transports } = require('winston'); - -const logger = createLogger({ - level: 'info', - exitOnError: false, - format: format.json(), - transports: [new transports.File({ filename: `/LogFiles/app.log`}), - ], -}); - -app.get("/", (_, res) => { - logger.info("Welcome!"); - res.sendStatus(200); -}); - -app.get("/hello", (_, res) => { - logger.info("Hello!"); - metricPrefix = "nodejs-azure-sidecar"; - // Send three unique metrics, just so we're testing more than one single metric - metricsToSend = ["sample_metric_1", "sample_metric_2", "sample_metric_3"]; - metricsToSend.forEach((metric) => { - for (let i = 0; i < 20; i++) { - tracer.dogstatsd.distribution(`${metricPrefix}.${metric}`, 1); - } - }); - res.status(200).json({ msg: "Sending metrics to Datadog" }); -}); - -const port = process.env.PORT || 8080; -app.listen(port); -``` - -{{% /tab %}} -{{% tab "Python" %}} -```py -from flask import Flask, Response -from datadog import initialize, statsd -import ddtrace -import logging - -ddtrace.patch(logging=True) - -FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] ' - '[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] ' - '- %(message)s') -logging.basicConfig(filename='/LogFiles/app.log', format=FORMAT) -log = logging.getLogger(__name__) -log.level = logging.INFO - -options = { - 'statsd_host':'127.0.0.1', - 'statsd_port':8125 -} - -initialize(**options) - -app = Flask(__name__) - -@app.route("/") -def home(): - statsd.increment('page.views') - log.info('Hello Datadog!!') - return Response('Datadog Self Monitoring 💜', status=200, mimetype='application/json') - -app.run(host="0.0.0.0", port=8080) -``` - -{{% /tab %}} -{{% tab "Java" %}} - -```java -package com.example.springboot; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.timgroup.statsd.NonBlockingStatsDClientBuilder; -import com.timgroup.statsd.StatsDClient; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -@RestController -public class HelloController { - private static final StatsDClient Statsd = new NonBlockingStatsDClientBuilder().hostname("localhost").port(8125).build(); - private static final Log logger = LogFactory.getLog(HelloController.class); - @GetMapping("/") - public String index() { - Statsd.incrementCounter("page.views"); - logger.info("Hello Azure!"); - return "💜 Hello Azure! 💜"; - } -} -``` - -{{% /tab %}} -{{% tab "Go" %}} - -```go -package main - -import ( - "fmt" - "log" - "net/http" - "os" - "path/filepath" - "github.com/DataDog/datadog-go/v5/statsd" - "github.com/DataDog/dd-trace-go/v2/ddtrace" - "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" -) - -const logDir = "/LogFiles" - -var logFile *os.File -var logCounter int -var dogstatsdClient *statsd.Client - -func handler(w http.ResponseWriter, r *http.Request) { - log.Println("Hello Datadog!") - span := tracer.StartSpan("maincontainer", tracer.ResourceName("/handler")) - defer span.Finish() - logCounter++ - writeLogsToFile(fmt.Sprintf("received request %d", logCounter), span.Context()) - dogstatsdClient.Incr("request.count", []string{}, 1) - fmt.Fprintf(w, "💜 Hello Datadog! 💜") -} - -func writeLogsToFile(log_msg string, context ddtrace.SpanContext) { - span := tracer.StartSpan( - "writeLogToFile", - tracer.ResourceName("/writeLogsToFile"), - tracer.ChildOf(context)) - defer span.Finish() - _, err := logFile.WriteString(log_msg + "\n") - if err != nil { - log.Println("Error writing to log file:", err) - } -} - -func main() { - log.Print("Main container started...") - - err := os.MkdirAll(logDir, 0755) - if err != nil { - panic(err) - } - logFilePath := filepath.Join(logDir, "app.log") - log.Println("Saving logs in ", logFilePath) - logFileLocal, err := os.OpenFile(logFilePath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) - if err != nil { - panic(err) - } - defer logFileLocal.Close() - - logFile = logFileLocal - - dogstatsdClient, err = statsd.New("localhost:8125") - if err != nil { - panic(err) - } - defer dogstatsdClient.Close() - - tracer.Start() - defer tracer.Stop() - - http.HandleFunc("/", handler) - log.Fatal(http.ListenAndServe(":8080", nil)) -} -``` - -{{% /tab %}} -{{% tab ".NET" %}} - -```csharp -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Serilog; -using Serilog.Formatting.Json; -using Serilog.Formatting.Compact; -using Serilog.Sinks.File; -using StatsdClient; - -namespace dotnet.Pages; - -public class IndexModel : PageModel -{ - private readonly static DogStatsdService _dsd; - static IndexModel() - { - var dogstatsdConfig = new StatsdConfig - { - StatsdServerName = "127.0.0.1", - StatsdPort = 8125, - }; - - _dsd = new DogStatsdService(); - _dsd.Configure(dogstatsdConfig); - - Log.Logger = new LoggerConfiguration() - .WriteTo.File(new RenderedCompactJsonFormatter(), "/LogFiles/app.log") - .CreateLogger(); - } - public void OnGet() - { - _dsd.Increment("page.views"); - Log.Information("Hello Cloud Run!"); - } -} -``` - -{{% /tab %}} -{{% tab "PHP" %}} -```php - '127.0.0.1', - 'port' => 8125, - ) - ); - -$log = new logger('datadog'); -$formatter = new JsonFormatter(); - -$stream = new StreamHandler('/LogFiles/app.log', Logger::DEBUG); -$stream->setFormatter($formatter); - -$log->pushHandler($stream); - -$log->info("Hello Datadog!"); -echo '💜 Hello Datadog! 💜'; - -$log->info("sending a metric"); -$statsd->increment('page.views', 1, array('environment'=>'dev')); - -?> -``` - -{{% /tab %}} -{{< /tabs >}} - -## Referencias adicionales - -{{< partial name="whats-next/whats-next.html" >}} - - -[1]: /es/integrations/azure/#log-collection -[2]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage -[3]: https://app.datadoghq.com/organization-settings/api-keys diff --git a/content/ja/serverless/azure_container_apps/_index.md b/content/ja/serverless/azure_container_apps/_index.md deleted file mode 100644 index 638b485c72c..00000000000 --- a/content/ja/serverless/azure_container_apps/_index.md +++ /dev/null @@ -1,162 +0,0 @@ ---- -further_reading: -- link: https://www.datadoghq.com/blog/azure-container-apps/ - tag: GitHub - text: Container Apps サービスからのトレース、ログ、カスタムメトリクスの収集 -title: Azure Container Apps ---- - -## 概要 -Azure Container Apps is a fully managed serverless platform for deploying and scaling container-based applications. Datadog provides monitoring and log collection for Container Apps through the [Azure integration][1]. Datadog also provides a solution for instrumenting your Container Apps applications with a Serverless Agent to enable tracing, custom metrics, and direct log collection. - -### 前提条件 - -[Datadog API キー][6]を取得済みであることと、[Datadog トレーシングライブラリがサポートする][2]プログラミング言語を使用していることを確認してください。 - -## アプリケーションをインスツルメントする - -アプリケーションをインスツルメンテーションするには、[Dockerfile](#dockerfile) と[ビルドパック](#buildpack)の 2 つの方法があります。 - -### Dockerfile - -Datadog publishes new releases of the serverless-init container image to Google's gcr.io, AWS' ECR, and on Docker Hub: - -| hub.docker.com | gcr.io | public.ecr.aws | -| ---- | ---- | ---- | -| datadog/serverless-init | gcr.io/datadoghq/serverless-init | public.ecr.aws/datadog/serverless-init | - -イメージはセマンティックバージョニングに基づいてタグ付けされ、新しいバージョンごとに 3 つの関連タグが付与されます。 - -* `1`、`1-alpine`: 重大な変更がない最新のマイナーリリースを追跡する場合、これらを使用します -* `1.x.x`、`1.x.x-alpine`: ライブラリの正確なバージョンにピン留めする場合、これらを使用します -* `latest`、`latest-alpine`: 重大な変更が含まれる可能性がある最新のバージョンリリースに従う場合、これらを使用します - -## `serverless-init` の動作 - -`serverless-init` アプリケーションはプロセスをラップし、サブプロセスとしてこれを実行します。このアプリケーションはメトリクス用の DogStatsD リスナーとトレース用の Trace Agent リスナーを起動します。アプリケーションの stdout/stderr ストリームをラップすることでログを収集します。ブートストラップの後、serverless-init はサブプロセスとしてコマンドを起動します。 - -完全なインスツルメンテーションを得るには、Docker コンテナ内で実行する最初のコマンドとして `datadog-init` を呼び出していることを確認します。これを行うには、エントリーポイントとして設定するか、CMD の最初の引数として設定します。 - -{{< programming-lang-wrapper langs="nodejs,python,java,go,dotnet,ruby,php" >}} -{{< programming-lang lang="nodejs" >}} - -{{% svl-init-nodejs %}} - -{{< /programming-lang >}} -{{< programming-lang lang="python" >}} - -{{% svl-init-python %}} - -{{< /programming-lang >}} -{{< programming-lang lang="java" >}} - -{{% svl-init-java %}} - -{{< /programming-lang >}} -{{< programming-lang lang="go" >}} - -{{% svl-init-go %}} - -{{< /programming-lang >}} -{{< programming-lang lang="dotnet" >}} - -{{% svl-init-dotnet %}} - -{{< /programming-lang >}} -{{< programming-lang lang="ruby" >}} - -{{% svl-init-ruby %}} - -{{< /programming-lang >}} -{{< programming-lang lang="php" >}} - -{{% svl-init-php %}} - -{{< /programming-lang >}} -{{< /programming-lang-wrapper >}} - -### 2. アプリケーションを構成する - -コンテナが構築され、レジストリにプッシュされたら、最後の手順として Datadog Agent 用に必要な環境変数を設定します。 -- `DD_API_KEY`: データを Datadog アカウントに送信するために使用する Datadog API キー。プライバシーと安全性の問題を考慮して、[Azure シークレット][7]に設定する必要があります。 -- `DD_SITE`: Datadog のエンドポイントと Web サイト。このページの右側で自分のサイトを選択します。あなたのサイトは {{< region-param key="dd_site" code="true" >}} です。 -- **`DD_AZURE_SUBSCRIPTION_ID`**: コンテナアプリリソースに関連付けられた Azure サブスクリプション ID (必須)。 -- **`DD_AZURE_RESOURCE_GROUP`**: コンテナアプリリソースに関連付けられた Azure リソースグループ (必須)。 - -- `DD_TRACE_ENABLED`: `true` に設定してトレースを有効にします。 - -環境変数とその機能の詳細については、[追加の構成](#additional-configurations)を参照してください。 - -次のコマンドはサービスをデプロイし、外部からの接続がサービスに到達できるようにするためのコマンドです。`DD_API_KEY` を環境変数として設定し、サービスのリスニングポートを 80 に設定します。 - -```shell -az containerapp up \ - --name APP_NAME \ - --resource-group RESOURCE_GROUP \ - --ingress external \ - --target-port 80 \ - --env-vars "DD_API_KEY=$DD_API_KEY" "DD_TRACE_ENABLED=true" "DD_SITE=datadoghq.com" \ - --image YOUR_REGISTRY/YOUR_PROJECT -``` - -### 3. 結果 - -Once the deployment is completed, your metrics and traces are sent to Datadog. In Datadog, navigate to [**Infrastructure > Serverless**][17] to see your serverless metrics and traces. - -## 追加の構成 - -- **高度なトレース:** Datadog Agent は、一般的なフレームワーク向けに基本的なトレース機能をすでにいくつか提供しています。さらに詳しい情報については、[高度なトレースガイド][2]に従ってください。 - -- **ログ:** [Azure インテグレーション][1]を使用している場合は、すでにログが収集されています。また、環境変数 `DD_LOGS_ENABLED` を `true` に設定することで、サーバーレスインスツルメンテーションを通じて直接アプリケーションログをキャプチャすることも可能です。 - -- **カスタムメトリクス:** [DogStatsd クライアント][3]を使って、カスタムメトリクスを送信することができます。Cloud Run やその他のサーバーレスアプリケーションの監視には、[ディストリビューション][8]メトリクスを使用します。ディストリビューションは、デフォルトで `avg`、`sum`、`max`、`min`、`count` の集計データを提供します。Metric Summary ページでは、パーセンタイル集計 (p50、p75、p90、p95、p99) を有効にすることができ、タグの管理も可能です。ゲージメトリクスタイプの分布を監視するには、[時間集計と空間集計][9]の両方で `avg` を使用します。カウントメトリクスタイプの分布を監視するには、時間集計と空間集計の両方で `sum` を使用します。 - -- **トレースサンプリング:** サーバーレスアプリケーションの APM トレースリクエストサンプリングレートを管理するには、関数の DD_TRACE_SAMPLE_RATE 環境変数を 0.000 (コンテナアプリのリクエストをトレースしない) から 1.000 (すべてのコンテナアプリのリクエストをトレースする) の間の値に設定します。 - -メトリクスは、アプリケーションの 100% のトラフィックに基づいて計算され、どのようなサンプリング構成であっても正確な値を維持します。 - -### 環境変数 - -| 変数 | 説明 | -| -------- | ----------- | -|`DD_API_KEY`| [Datadog API キー][6] - **必須**| -| `DD_SITE` | [Datadog サイト][4] - **必須** | -| `DD_LOGS_ENABLED` | true の場合、ログ (stdout と stderr) を Datadog に送信します。デフォルトは false です。 | -| `DD_LOGS_INJECTION`| true の場合、[Java][10]、[Node.js][11]、[.NET][12]、および [PHP][13] でサポートされているロガーのトレースデータですべてのログをリッチ化します。[Python][14]、[Go][15]、[Ruby][16] については追加のドキュメントを参照してください。 | -| `DD_TRACE_SAMPLE_RATE`| トレース取り込みのサンプルレート `0.0` と `1.0` をコントロールします| -| `DD_SERVICE` | [統合サービスタグ付け][5]を参照してください。 | -| `DD_VERSION` | [統合サービスタグ付け][5]を参照してください。 | -| `DD_ENV` | [統合サービスタグ付け][5]を参照してください。 | -| `DD_SOURCE` | [統合サービスタグ付け][5]を参照してください。 | -| `DD_TAGS` | [統合サービスタグ付け][5]を参照してください。 | - -## トラブルシューティング - -このインテグレーションは、お使いのランタイムが完全な SSL を実装しているかどうかに依存します。Node の slim イメージを使用している場合、証明書を含めるために Dockerfile に次のコマンドを追加する必要があるかもしれません。 - -``` -RUN apt-get update && apt-get install -y ca-certificates -``` - -## 参考資料 - -{{< partial name="whats-next/whats-next.html" >}} - - -[1]: /ja/integrations/azure/#log-collection -[2]: /ja/tracing/trace_collection/#for-setup-instructions-select-your-language -[3]: /ja/metrics/custom_metrics/dogstatsd_metrics_submission/ -[4]: /ja/getting_started/site/ -[5]: /ja/getting_started/tagging/unified_service_tagging/ -[6]: /ja/account_management/api-app-keys/ -[7]: https://learn.microsoft.com/en-us/azure/container-apps/manage-secrets -[8]: /ja/metrics/distributions/ -[9]: /ja/metrics/#time-and-space-aggregation -[10]: /ja/tracing/other_telemetry/connect_logs_and_traces/java/?tab=log4j2 -[11]: /ja/tracing/other_telemetry/connect_logs_and_traces/nodejs -[12]: /ja/tracing/other_telemetry/connect_logs_and_traces/dotnet?tab=serilog -[13]: /ja/tracing/other_telemetry/connect_logs_and_traces/php -[14]: /ja/tracing/other_telemetry/connect_logs_and_traces/python -[15]: /ja/tracing/other_telemetry/connect_logs_and_traces/go -[16]: /ja/tracing/other_telemetry/connect_logs_and_traces/ruby -[17]: https://app.datadoghq.com/functions?cloud=azure&entity_view=container_apps \ No newline at end of file diff --git a/content/ko/serverless/azure_container_apps/_index.md b/content/ko/serverless/azure_container_apps/_index.md deleted file mode 100644 index 44f9da10a57..00000000000 --- a/content/ko/serverless/azure_container_apps/_index.md +++ /dev/null @@ -1,291 +0,0 @@ ---- -further_reading: -- link: https://www.datadoghq.com/blog/azure-container-apps/ - tag: 블로그 - text: 컨테이너 앱 서비스에서 트레이스, 로그 및 커스텀 메트릭 수집 -title: Azure 컨테이너 앱 ---- - -## 개요 -Azure 컨테이너 앱은 컨테이너 기반 애플리케이션을 배포하고 확장하기 위한 완전 관리형 서버리스 플랫폼입니다. Datadog은 [Azure 통합][1]을 통해 컨테이너 앱에 대한 모니터링 및 로그 수집을 제공합니다. 또한 Datadog은 트레이스, 커스텀 메트릭, 직접 로그 수집을 지원하는 전용 에이전트로 컨테이너 앱 애플리케이션을 계측할 수 있는 솔루션(현재 베타 버전)을 제공합니다. - -
이 기능은 베타 버전입니다. 표준 지원 채널을 통해 피드백을 제공할 수 있습니다. 베타 기간 동안에는 직접 비용 없이 컨테이너 앱 모니터링 및 APM 추적을 사용할 수 있습니다. 기존 APM 고객은 스팬 수집 및 볼륨 비용이 증가할 수 있습니다.
- -## 시작하기 - -### 전제 조건 - -[Datadog API 키][6]가 있고 [Datadog 트레이싱 라이브러리에서 지원되는][2] 프로그래밍 언어를 사용하고 있는지 확인하세요. - -### 1. 애플리케이션 계측 - -{{< programming-lang-wrapper langs="go,python,nodejs,java,dotnet,ruby" >}} -{{< programming-lang lang="go" >}} - -#### Dockerfile을 사용해 에이전트 설치 - -Dockerfile에 다음 줄을 추가하여 Datadog 에이전트를 사용해 애플리케이션을 계측할 수 있습니다. 기존 Dockerfile 설정에 따라 이러한 예를 조정해야 할 수 있습니다. - -``` -# Datadog `serverless-init`를 도커 이미지에 복사합니다. -COPY --from=datadog/serverless-init /datadog-init /app/datadog-init - -# 애플리케이션을 Datadog serverless-init 프로세스로 래핑하도록 엔트리포인트를 변경합니다. -ENTRYPOINT ["/app/datadog-init"] - -# 필요 시 Datadog 태그를 추가합니다. -ENV DD_SERVICE=datadog-demo-run-go -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 - -# 엔트리포인트로 래핑된 바이너리 애플리케이션을 실행합니다. 이 줄을 필요에 맞게 조정하세요. -CMD ["/path/to/your-go-binary"] -``` - -#### 추적 라이브러리 설치 -[이 지침][2]에 따라 애플리케이션에 Go 추적 라이브러리를 설치 및 설정하여 트레이스를 캡처하고 제출하세요. - - -[단순한 Go 애플리케이션을 위한 샘플 코드][1] - - -[1]: https://github.com/DataDog/crpb/tree/main/go -[2]: /ko/tracing/trace_collection/dd_libraries/go/?tab=containers#installation-and-getting-started - -{{< /programming-lang >}} -{{< programming-lang lang="python" >}} - -#### Dockerfile을 사용해 에이전트 설치 - -Dockerfile 파일에 다음 줄을 추가하여 Datadog 에이전트를 사용해 애플리케이션을 계측할 수 있습니다. 기존 Dockerfile 설정에 따라 이러한 예를 조정해야 할 수 있습니다. - -``` -# Datadog `serverless-init`을 도커 이미지에 복사합니다. -COPY --from=datadog/serverless-init /datadog-init /app/datadog-init - -# 여기 또는 requirements.txt에 python 추적 라이브러리를 설치하세요. -RUN pip install --no-cache-dir ddtrace==1.7.3 - -# 필요 시 Datadog 태그를 추가합니다. -ENV DD_SERVICE=datadog-demo-run-python -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 - -# 애플리케이션을 Datadog serverless-init 프로세스로 래핑하도록 엔트리포인트를 변경합니다. -ENTRYPOINT ["/app/datadog-init"] - -# Datadog 추적 라이브러리가 시작하고, 엔트리포인트에서 래핑된 바이너리 애플리케이션을 실행합니다. 이 줄을 필요에 맞게 조정하세요. -CMD ["ddtrace-run", "python", "app.py"] -``` -#### 추적 라이브러리 설치 -[이 지침][2]을 따라 애플리케이션에서 Python 트레이싱 라이브러리를 설치 및 설정하여 트레이스를 캡처하고 제출합니다. - -[단순한 Python 애플리케이션을 위한 샘플 코드][1] - -[1]: https://github.com/DataDog/crpb/tree/main/python -[2]: /ko/tracing/trace_collection/dd_libraries/python/?tab=containers#instrument-your-application - -{{< /programming-lang >}} -{{< programming-lang lang="nodejs" >}} - -#### Dockerfile을 사용해 에이전트 설치 - -Dockerfile 파일에 다음 줄을 추가하여 Datadog 에이전트를 사용해 애플리케이션을 계측할 수 있습니다. 기존 Dockerfile 설정에 따라 이러한 예를 조정해야 할 수 있습니다. - -``` -# Datadog `serverless-init`를 도커 이미지에 복사합니다. -COPY --from=datadog/serverless-init /datadog-init /app/datadog-init - -# 여기 또는 package.json에서 Datadog js 추적 라이브러리를 설치합니다. - -RUN npm i dd-trace@2.2.0 - -# Datadog 추적 라이브러리를 활성화합니다. -ENV NODE_OPTIONS="--require dd-trace/init" - -# 필요 시 Datadog 태그를 추가합니다. -ENV DD_SERVICE=datadog-demo-run-nodejs -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 - -# 애플리케이션을 Datadog serverless-init 프로세스로 래핑하도록 엔트리포인트를 변경합니다. -ENTRYPOINT ["/app/datadog-init"] - -# 엔트리포인트에서 래핑된 바이너리 애플리케이션을 실행합니다. 이 줄을 필요에 맞게 조정하세요. -CMD ["/nodejs/bin/node", "/path/to/your/app.js"] - -``` -#### 추적 라이브러리 설치 -[이 지침][2]을 따라 애플리케이션에서 Node 트레이싱 라이브러리를 설치 및 설정하여 트레이스를 캡처하고 제출합니다. - -[단순한 Node.js 애플리케이션을 위한 샘플 코드][1] - -[1]: https://github.com/DataDog/crpb/tree/main/js -[2]: /ko/tracing/trace_collection/dd_libraries/nodejs/?tab=containers#instrument-your-application - -{{< /programming-lang >}} -{{< programming-lang lang="java" >}} - -#### Dockerfile을 사용해 에이전트 설치 - -Dockerfile 파일에 다음 줄을 추가하여 Datadog 에이전트를 사용해 애플리케이션을 계측할 수 있습니다. 기존 Dockerfile 설정에 따라 이러한 예를 조정해야 할 수 있습니다. - -``` -# Datadog `serverless-init`을 도커 이미지에 복사합니다. -COPY --from=datadog/serverless-init /datadog-init /app/datadog-init - -# 필요 시 Datadog 태그를 추가합니다. -ENV DD_SERVICE=datadog-demo-run-java -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 - -# 애플리케이션을 Datadog serverless-init 프로세스로 래핑하도록 엔트리포인트를 변경합니다. -ENTRYPOINT ["/app/datadog-init"] - -# 엔트리포인트에서 래핑된 바이너리 애플리케이션을 실행합니다. 이 줄을 필요에 맞게 조정하세요. -CMD ["./mvnw", "spring-boot:run"] - -``` - -#### 추적 라이브러리 설치 -[이 지침][2]을 따라 애플리케이션에서 Java 트레이싱 라이브러리를 설치 및 설정하여 트레이스를 캡처하고 제출합니다. - -[단순한 Java 애플리케이션을 위한 샘플 코드][1] - -[1]: https://github.com/DataDog/crpb/tree/main/java -[2]: /ko/tracing/trace_collection/dd_libraries/java/?tab=containers#instrument-your-application - -{{< /programming-lang >}} -{{< programming-lang lang="dotnet" >}} - -#### Dockerfile을 사용해 에이전트 설치 - -Dockerfile 파일에 다음 줄을 추가하여 Datadog 에이전트를 사용해 애플리케이션을 계측할 수 있습니다. 기존 Dockerfile 설정에 따라 이러한 예를 조정해야 할 수 있습니다. - -``` -# Datadog `serverless-init`을 도커 이미지에 복사합니다. -COPY --from=datadog/serverless-init /datadog-init /app/datadog-init - -# 필요 시 Datadog 태그를 추가합니다. -ENV DD_SERVICE=datadog-demo-run-dotnet -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 - -# 애플리케이션을 Datadog serverless-init 프로세스로 래핑하도록 엔트리포인트를 변경합니다. -ENTRYPOINT ["/app/datadog-init"] - -# 엔트리포인트에서 래핑된 바이너리 애플리케이션을 실행합니다. 이 줄을 필요에 맞게 조정하세요. -CMD ["dotnet", "helloworld.dll"] - -``` - -#### 추적 라이브러리 설치 -[이 지침][2]을 따라 [.NET Core 트레이싱 라이브러리][1] 및 [.NET Framework 트레이싱 라이브러리][2]를 설치하고 설정합니다. - -[1]: /ko/tracing/trace_collection/dd_libraries/dotnet-core?tab=containers#custom-instrumentation -[2]: /ko/tracing/trace_collection/dd_libraries/dotnet-framework/?tab=containers#custom-instrumentation - -{{< /programming-lang >}} -{{< programming-lang lang="ruby" >}} - -#### Dockerfile을 사용해 에이전트 설치 - -Dockerfile 파일에 다음 줄을 추가하여 Datadog 에이전트를 사용해 애플리케이션을 계측할 수 있습니다. 기존 Dockerfile 설정에 따라 이러한 예를 조정해야 할 수 있습니다. - -``` -# Datadog `serverless-init`을 도커 이미지에 복사합니다. -COPY --from=datadog/serverless-init /datadog-init /app/datadog-init - -# 필요 시 Datadog 태그를 추가합니다. -ENV DD_SERVICE=datadog-demo-run-ruby -ENV DD_ENV=datadog-demo -ENV DD_VERSION=1 - -# 애플리케이션을 Datadog serverless-init 프로세스로 래핑하도록 엔트리포인트를 변경합니다. -ENTRYPOINT ["/app/datadog-init"] - -# 엔트리포인트에서 래핑된 바이너리 애플리케이션을 실행합니다. 이 줄을 필요에 맞게 조정하세요. -CMD ["rails", "server", "-b", "0.0.0.0"] (adapt this line to your needs) - -``` - -#### 추적 라이브러리 설치 - -[이 지침][2]을 따라 애플리케이션에서 Ruby 트레이싱 라이브러리를 설치 및 설정하여 트레이스를 캡처하고 제출합니다. - -[단순한 Ruby 애플리케이션을 위한 샘플 코드][1] - -[1]: https://github.com/DataDog/crpb/tree/main/ruby-on-rails -[2]: /ko/tracing/trace_collection/dd_libraries/ruby/?tab=containers#instrument-your-application - -{{< /programming-lang >}} -{{< /programming-lang-wrapper >}} - -### 2. 애플리케이션 설정 - -컨테이너가 만들어진 후 레지스트리에 푸시되면 마지막 단계는 Datadog 에이전트를 위한 필수 환경 변수를 설정하는 것입니다: -- `DD_API_KEY`: Datadog API 키로 Datadog 계정에 데이터를 전송하는 데 사용됩니다. 개인정보 보호와 안전을 위해 [Azure Secret][7]으로 설정해야 합니다. -- `DD_SITE`: Datadog 엔드포인트와 웹사이트입니다. 페이지 오른쪽에서 사이트를 선택합니다. 사이트는 {{< region-param key="dd_site" code="true" >}}입니다. -- `DD_TRACE_ENABLED`: 트레이싱 활성화를 위해 `true`로 설정합니다. - -환경 변수와 기능에 대한 자세한 정보는 [추가 설정](#additional-configurations)을 참조하세요. - -이 명령은 서비스를 구축하고 외부 연결이 서비스에 도달하도록 허용합니다. `DD_API_KEY`를 환경 변수로 설정하고 서비스가 포트 80에 연결되도록 설정합니다. - -```shell -az containerapp up \ - --name APP_NAME \ - --resource-group RESOURCE_GROUP \ - --ingress external \ - --target-port 80 \ - --env-vars "DD_API_KEY=$DD_API_KEY" "DD_TRACE_ENABLED=true" "DD_SITE='datadoghq.com'" \ - --image YOUR_REGISTRY/YOUR_PROJECT -``` - -### 3. 결과 - -구축이 완료되면 메트릭과 트레이스는 Datadog로 전송됩니다. Datadog에서 **인프라스트럭처->서버리스**로 이동하여 서버리스 메트릭과 트레이스를 확인합니다. - -## 추가 설정 - -- **고급 트레이싱**: Datadog 에이전트는 이미 인기 프레임워크에 대한 기본 트레이싱을 제공합니다. 자세한 정보는 [고급 트레이싱 가이드][2]를 참조하세요. - -- **로그**: [Azure 통합][1]을 사용하는 경우 이미 로그가 수집됩니다. 대신 `DD_LOGS_ENABLED` 환경 변수를 `true`로 설정하여 직접 서버리스 계측으로 애플리케이션 로그를 캡처할 수 있습니다. - -- **커스텀 메트릭**: [DogStatsd 클라이언트][3]를 사용해 커스텀 메트릭을 제출할 수 있습니다. Cloud Run 및 기타 서버리스 애플리케이션의 경우 [분포][8] 메트릭을 사용합니다. 분포는 `avg`, `sum`, `max`, `min`, `count` 집계를 기본적으로 제공합니다. 메트릭 요약 페이지에서 백분위수 집계 (p50, p75, p90, p95, p99)를 활성화할 수 있습니다. 게이지 메트릭 유형에 대한 분포를 모니터링하려면 [시간 및 공간 집계][11] 모두에 대해 `avg`를 사용합니다. 카운터 메트릭 유형에 대한 분포를 모니터링하려면 시간 및 공간 집계 모두에 `sum`을 사용합니다. - -### 환경 변수 - -| 변수 | 설명 | -| -------- | ----------- | -|`DD_API_KEY`| [Datadog API 키][6] - **필수**| -| `DD_SITE` | [Datadog 사이트][4] - **필수** | -| `DD_LOGS_ENABLED` | true인 경우 로그 (stdout 및 stderr)를 Datadog에 전송합니다. 기본값은 false입니다. | -| `DD_SERVICE` | [통합 서비스 태깅][5]을 참조하세요. | -| `DD_VERSION` | [통합 서비스 태깅][5]을 참조하세요. | -| `DD_ENV` | [통합 서비스 태깅][5]을 참조하세요. | -| `DD_SOURCE` | [통합 서비스 태깅][5]을 참조하세요. | -| `DD_TAGS` | [통합 서비스 태깅][5]을 참조하세요. | - -## 문제 해결 - -이 통합은 전체 SSL 구현 환경을 포함하는 런타임에 따라 달라집니다. Node에 대해 슬림 이미지를 사용하는 경우 Dockerfile에 다음 명령을 추가하여 인증서를 포함해야 할 수 있습니다. - -``` -RUN apt-get update && apt-get install -y ca-certificates -``` - -## 참고 자료 - -{{< partial name="whats-next/whats-next.html" >}} - - -[1]: /ko/integrations/azure/#log-collection -[2]: /ko/tracing/trace_collection/#for-setup-instructions-select-your-language -[3]: /ko/metrics/custom_metrics/dogstatsd_metrics_submission/ -[4]: /ko/getting_started/site/ -[5]: /ko/getting_started/tagging/unified_service_tagging/ -[6]: /ko/account_management/api-app-keys/ -[7]: https://learn.microsoft.com/en-us/azure/container-apps/manage-secrets -[8]: /ko/metrics/distributions/ -[9]: /ko/metrics/#time-and-space-aggregation \ No newline at end of file diff --git a/customization_config/en/option_groups/serverless.yaml b/customization_config/en/option_groups/serverless.yaml new file mode 100644 index 00000000000..978c22074c0 --- /dev/null +++ b/customization_config/en/option_groups/serverless.yaml @@ -0,0 +1,18 @@ +# Serverless (Azure Container Apps, Cloud Run, etc.) option groups + +# Question: How do you want to deploy the Datadog Agent alongside your app? +aca_instrumentation_method_options: + - id: in_container + default: true + - id: sidecar + +# Question: Which application runtime are you instrumenting? +aca_runtime_options: + - id: python + default: true + - id: node_js + - id: go + - id: java + - id: dot_net + - id: ruby + - id: php diff --git a/customization_config/en/options/general.yaml b/customization_config/en/options/general.yaml index acaf1de824a..95a2480705d 100644 --- a/customization_config/en/options/general.yaml +++ b/customization_config/en/options/general.yaml @@ -208,6 +208,9 @@ options: - label: SOCKS id: socks +- label: In-Container + id: in_container + - label: iOS id: ios @@ -385,6 +388,9 @@ options: - label: Show all id: show_all +- label: Sidecar + id: sidecar + - label: Splunk HEC id: splunk_hec diff --git a/customization_config/en/traits/serverless.yaml b/customization_config/en/traits/serverless.yaml new file mode 100644 index 00000000000..6f89c18bbff --- /dev/null +++ b/customization_config/en/traits/serverless.yaml @@ -0,0 +1,5 @@ +traits: +- id: instrumentation_method + label: "Instrumentation method" + type: text + internal_notes: How the Datadog Agent is deployed alongside a serverless workload, such as in-container (single container) or sidecar (separate container). diff --git a/layouts/shortcodes/mdoc/en/serverless/aca-sidecar-install-methods.mdoc.md b/layouts/shortcodes/mdoc/en/serverless/aca-sidecar-install-methods.mdoc.md new file mode 100644 index 00000000000..803ef0158ce --- /dev/null +++ b/layouts/shortcodes/mdoc/en/serverless/aca-sidecar-install-methods.mdoc.md @@ -0,0 +1,411 @@ + + +{% partial file="serverless/serverless-init-image.mdoc.md" /%} + +{% tabs %} + +{% tab label="Datadog CLI" %} + +#### Locally + +Install the Datadog CLI: + +```shell +npm install -g @datadog/datadog-ci @datadog/datadog-ci-plugin-container-app +``` + +Install the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) and authenticate with `az login`. + +To set up the Datadog sidecar for your applications, configure the [Datadog site](/getting_started/site/) and Datadog API key, and run the `instrument` command *after* your normal deployment: + +```shell +export DD_SITE="" +export DD_API_KEY="" +datadog-ci container-app instrument -s -g -n +``` + +You can also instrument multiple applications using the full resource IDs: + +```shell +datadog-ci container-app instrument \ + --resource-id "/subscriptions//resourceGroups//providers/Microsoft.App/containerApps/" \ + --resource-id "/subscriptions//resourceGroups//providers/Microsoft.App/containerApps/" +``` + +##### Azure Cloud Shell + +To use the Datadog CLI in [Azure Cloud Shell](https://portal.azure.com/#cloudshell/), open a cloud shell, set your API key and site in the `DD_API_KEY` and `DD_SITE` environment variables, and use `npx` to run the CLI directly. + +```shell +export DD_API_KEY= +export DD_SITE= +npx @datadog/datadog-ci container-app instrument -s -g -n +``` + +Additional parameters can be found in the [CLI documentation](https://github.com/DataDog/datadog-ci/tree/master/packages/plugin-container-app#arguments). + +{% /tab %} + +{% tab label="Terraform" %} + +The [Datadog Terraform module for Container Apps](https://registry.terraform.io/modules/DataDog/container-app-datadog/azurerm/latest) wraps the [`azurerm_container_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app) resource and automatically configures your Azure Container App for Datadog Serverless Monitoring by adding required environment variables and the serverless-init sidecar. + +If you don't already have Terraform set up, [install Terraform](https://developer.hashicorp.com/terraform/install), create a new directory, and make a file called `main.tf`. + +Then, add the following to your Terraform configuration, updating it as necessary based on your needs: + +```tf +variable "datadog_api_key" { + description = "Your Datadog API key" + type = string + sensitive = true +} + +provider "azurerm" { + features {} + subscription_id = "00000000-0000-0000-0000-000000000000" // Replace with your subscription ID +} + +resource "azurerm_container_app_environment" "my_env" { + name = "my-container-app-env" // Replace with your container app environment name + resource_group_name = "my-resource-group" // Replace with your resource group name + location = "eastus" +} + +module "my_container_app" { + source = "DataDog/container-app-datadog/azurerm" + version = "~> 1.0" + + name = "my-container-app" // Replace with your container app name + resource_group_name = "my-resource-group" // Replace with your resource group name + container_app_environment_id = azurerm_container_app_environment.my_env.id + + datadog_api_key = var.datadog_api_key + datadog_site = "datadoghq.com" // Replace with your Datadog site + datadog_service = "my-service" // Replace with your service name + datadog_env = "dev" // Replace with your environment (e.g. prod, staging, dev) + datadog_version = "0.1.0" // Replace with your application version + + revision_mode = "Single" + workload_profile_name = "Consumption" + ingress = { + external_enabled = true + target_port = 8080 + traffic_weight = [{ + percentage = 100 + latest_revision = true + }] + } + template = { + container = [{ + cpu = 0.5 + memory = "1Gi" + image = "docker.io/your-docker-image:latest" // Replace with your Docker image + name = "main" + }] + } +} +``` + +Finally, run `terraform apply`, and follow any prompts. + +The [Datadog Container App module](https://registry.terraform.io/modules/DataDog/container-app-datadog/azurerm/latest) only deploys the Container App resource, so you need to build and push your container separately. + +See the [Environment variables](#environment-variables) section for more information on the configuration options available through the `env`. + +Make sure the container port for the main container matches the one exposed in your Dockerfile/service. + +If you haven't already, initialize your Terraform project: + +```shell +terraform init +``` + +To deploy your app, run: + +```shell +terraform apply +``` + +{% /tab %} + +{% tab label="Bicep" %} + +Update your existing Container App bicep to include the necessary Datadog App Settings and sidecar, as follows: + +```bicep +@secure() +param datadogApiKey string +param datadogSite string +param service string = 'my-service' +param env string = 'dev' +param version string = '0.0.0' + +resource containerApp 'Microsoft.App/containerApps@2024-03-01' = { + // ... + properties: { + template: { + volumes: [ + { + name: 'shared-volume' + storageType: 'EmptyDir' + } + // Additional volumes + ] + containers: [ + { + name: 'main' + image: 'index.docker.io/your/image:tag' // Replace with your Application Image + resources: { + cpu: 1 + memory: '2Gi' + } + env: [ + { name: 'DD_ENV', value: env } + { name: 'DD_SERVICE', value: name } + { name: 'DD_VERSION', value: version } + { name: 'DD_LOGS_INJECTION', value: 'true' } + // Additional tracing/application env vars + ] + volumeMounts: [ + { volumeName: 'shared-volume', mountPath: '/shared-volume' } + // Additional volume mounts + ] + } + { + name: 'datadog-sidecar' + image: 'index.docker.io/datadog/serverless-init:latest' + resources: { + cpu: '0.5' + memory: '1Gi' + } + env: [ + { name: 'DD_AZURE_SUBSCRIPTION_ID', value: subscription().subscriptionId } + { name: 'DD_AZURE_RESOURCE_GROUP', value: resourceGroup().name } + { name: 'DD_API_KEY', value: datadogApiKey } + { name: 'DD_SITE', value: datadogSite } + { name: 'DD_SERVICE', value: service } + { name: 'DD_ENV', value: env } + { name: 'DD_VERSION', value: version } + // set this to wherever you write logs in the shared volume: + { name: 'DD_SERVERLESS_LOG_PATH', value: '/shared-volume/logs/app.log' } + ] + volumeMounts: [{ volumeName: 'shared-volume', mountPath: '/shared-volume' }] + } + ] + scale: { minReplicas: 1, maxReplicas: 1, rules: [] } + } + } +} +``` + +Redeploy your updated template: + +```shell +az deployment group create --resource-group --template-file