-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCS-10117: Add .NET instructions to AAS #27599
Open
cswatt
wants to merge
3
commits into
master
Choose a base branch
from
cswatt/aas-dotnet-sidecar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,74 @@ | |
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=java#code-examples | ||
[3]: /logs/log_collection/java/?tab=winston30 | ||
[4]: /tracing/other_telemetry/connect_logs_and_traces/java | ||
{{% /tab %}} | ||
{{% tab ".NET" %}} | ||
#### Tracing | ||
Instrument your main application with the `dd-trace-dotnet` library. | ||
|
||
1. Add the following lines to the Dockerfile for your main application. This installs and configures the Datadog tracer within your application container. | ||
{{< code-block lang="dockerfile" >}} | ||
RUN mkdir -p /datadog/tracer | ||
RUN mkdir -p /home/LogFiles/dotnet | ||
|
||
ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.51.0/datadog-dotnet-apm-2.49.0.tar.gz /datadog/tracer | ||
RUN cd /datadog/tracer && tar -zxf datadog-dotnet-apm-2.49.0.tar.gz | ||
{{< /code-block >}} | ||
|
||
2. Build the image and push it to your preferred container registry. | ||
|
||
**Full example Dockerfile** | ||
|
||
{{< highlight dockerfile "hl_lines=22-27" >}} | ||
# Stage 1: Build the application | ||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
WORKDIR /app | ||
|
||
# Copy the project file and restore dependencies | ||
COPY *.csproj ./ | ||
RUN dotnet restore | ||
|
||
# Copy the remaining source code | ||
COPY . . | ||
|
||
# Build the application | ||
RUN dotnet publish -c Release -o out | ||
|
||
# Stage 2: Create a runtime image | ||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime | ||
WORKDIR /app | ||
|
||
# Copy the build output from stage 1 | ||
COPY --from=build /app/out ./ | ||
|
||
# Datadog specific | ||
RUN mkdir -p /datadog/tracer | ||
RUN mkdir -p /home/LogFiles/dotnet | ||
|
||
ADD https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.49.0/datadog-dotnet-apm-2.49.0.tar.gz /datadog/tracer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above for this link. |
||
RUN cd /datadog/tracer && tar -zxf datadog-dotnet-apm-2.49.0.tar.gz | ||
|
||
# Set the entry point for the application | ||
ENTRYPOINT ["dotnet", "<your dotnet app>.dll"] | ||
{{< /highlight >}} | ||
|
||
For more information, see [Tracing .NET Applications][1]. | ||
|
||
#### Metrics | ||
Custom metrics are also collected through the tracer. See the [code examples][2]. | ||
|
||
#### Logs | ||
The Datadog sidecar uses file tailing to collect logs. Datadog recommends writing application logs to `/home/LogFiles/` because this directory is persisted across restarts. | ||
|
||
You can also create a subdirectory, such as `/home/LogFiles/myapp`, if you want more control over what is sent to Datadog. However, if you do not tail all log files in `/home/LogFiles`, then Azure App Service application logs related to startups and errors are not collected. | ||
|
||
To set up logging in your application, see [C# Log Collection][3]. To set up trace log correlation, see [Correlating .NET Logs and Traces][4]. | ||
|
||
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core | ||
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=dotnet#code-examples | ||
[3]: /logs/log_collection/csharp | ||
[4]: /tracing/other_telemetry/connect_logs_and_traces/dotnet | ||
|
||
{{% /tab %}} | ||
{{% tab "Go" %}} | ||
#### Tracing | ||
|
@@ -137,6 +205,22 @@ | |
- `DD_ENV`: How you want to tag your env. For example, `prod` | ||
- `DD_SERVERLESS_LOG_PATH`: Where you write your logs. For example, `/home/LogFiles/*.log` or `/home/LogFiles/myapp/*.log` | ||
|
||
<details open> | ||
<summary> | ||
<h4>For .NET applications: Additional required environment variables</h4> | ||
</summary> | ||
|
||
If you are setting up monitoring for a .NET application, configure the following **required** environment variables. | ||
|
||
| Variable name | Value | | ||
| ------------- | ----- | | ||
| `DD_DOTNET_TRACER_HOME` | `/datadog/tracer` | | ||
| `DD_TRACE_LOG_DIRECTORY` | `/home/Logfiles/dotnet` | | ||
| `CORECLR_ENABLE_PROFILING` | `1` | | ||
| `CORECLR_PROFILER` | `{846F5F1C-F9AE-4B07-969E-05C26BC060D8}` | | ||
| `CORECLR_PROFILER_PATH` | `/datadog/tracer/Datadog.Trace.ClrProfiler.Native.so` | | ||
</details> | ||
|
||
## Example application | ||
The following example contains a single app with tracing, metrics, and logs set up. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this link is incorrect. It says
Not Found
whereas my suggested update downloads the file.