Skip to content

Commit

Permalink
[feature/9.x] Sync branch with origin/main (#7308)
Browse files Browse the repository at this point in the history
* Update dependencies from https://github.com/dotnet/diagnostics build 20240906.1 (#7285)

[main] Update dependencies from dotnet/diagnostics

* Add Docker Compose sample and cross link (#7276)

* Update public Linux build machines to Ubuntu 22.04 (#7283)

* Update release tool to .NET 8 and update dependencies (#7284)

* [main] Bump Swashbuckle.AspNetCore in /eng/dependabot/independent (#7288)

Bumps [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 6.7.1 to 6.7.3.
- [Release notes](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)
- [Commits](domaindrivendev/Swashbuckle.AspNetCore@v6.7.1...v6.7.3)

---
updated-dependencies:
- dependency-name: Swashbuckle.AspNetCore
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* generate release notes (#7294)

* Update dependencies from https://github.com/dotnet/diagnostics build 20240909.1 (#7295)

[main] Update dependencies from dotnet/diagnostics

* Update dependencies from https://github.com/dotnet/arcade build 20240909.4 (#7296)

[main] Update dependencies from dotnet/arcade

* Prevent collected exceptions from being dropped due to null event values (#7301)

* Register v9.0.0-rc.1.24453.3 release information (#7303)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update dependencies from https://github.com/dotnet/diagnostics build 20240910.1 (#7304)

[main] Update dependencies from dotnet/diagnostics

* Update dependencies from https://github.com/dotnet/arcade build 20240910.4 (#7305)

[main] Update dependencies from dotnet/arcade

* Restore branch-specific files

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Justin Anderson <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Joe Schmitt <[email protected]>
  • Loading branch information
5 people authored Sep 12, 2024
1 parent 62065ad commit dca8904
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
"outOfSupportDate": "2024-05-14T00:00:00.000Z"
},
"9.0": {
"tag": "v9.0.0-preview.7.24408.4",
"minorReleaseDate": "2024-08-13T00:00:00.000Z",
"patchReleaseDate": "2024-08-13T00:00:00.000Z",
"tag": "v9.0.0-rc.1.24453.3",
"minorReleaseDate": "2024-09-10T00:00:00.000Z",
"patchReleaseDate": "2024-09-10T00:00:00.000Z",
"supportedFrameworks": [
"net9.0"
]
Expand Down
1 change: 1 addition & 0 deletions documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ When running a dotnet application, differences in diverse local and production e
- Getting Started
- [Running on a local machine](./localmachine.md)
- [Running in Docker](./docker.md)
- [Running in Docker Compose](./docker-compose.md)
- [Running in Kubernetes](./kubernetes.md)
- [API Endpoints](./api/README.md)
- [OpenAPI document](./openapi.md)
Expand Down
106 changes: 106 additions & 0 deletions documentation/docker-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Running in Docker Compose

In addition to its availability as a .NET CLI tool, the `dotnet monitor` tool is available as a prebuilt Docker image that can be run in container runtimes and orchestrators, such as Docker Compose.

For Dockerfiles and repository information, see [Running in Docker](./docker.md)

For a Kubernetes sample, see [Running in Kubernetes](./kubernetes.md)

## Non-root considerations

Starting with .NET 8.0, both the sample ASP.NET application and dotnet-monitor run as non-root. If both the application and dotnet-monitor are 8+, no additional configuration is required. Otherwise, a [user](https://docs.docker.com/reference/compose-file/services/#user) configuration may need to be added to the application, dotnet-monitor, or both.

## Example Deployment

The following examples demonstrate a deployment of the dotnet-monitor container image monitoring an application container as services.

<details>
<summary>.NET Monitor 8+</summary>

```yaml
# Tell us about your experience using dotnet monitor: https://aka.ms/dotnet-monitor-survey
services:
app:
image: mcr.microsoft.com/dotnet/samples:aspnetapp-chiseled
ports:
- "8080:8080"
environment:
- DOTNET_DiagnosticPorts=/diag/dotnet-monitor.sock
volumes:
- diagvol:/diag
deploy:
resources:
limits:
cpus: '0.250'
memory: 512M

monitor:
image: mcr.microsoft.com/dotnet/monitor:8
# DO NOT use the --no-auth argument for deployments in production; this argument is used for demonstration
# purposes only in this example. Please continue reading after this example for further details.
command: ["collect", "--no-auth"]
ports:
- "52323:52323"
- "52325:52325"
environment:
- DOTNETMONITOR_DiagnosticPort__ConnectionMode=Listen
- DOTNETMONITOR_Storage__DefaultSharedPath=/diag
# ALWAYS use the HTTPS form of the URL for deployments in production; the removal of HTTPS is done for
# demonstration purposes only in this example. Please continue reading after this example for further details.
- DOTNETMONITOR_Urls=http://+:52323
# The metrics URL is set in the CMD instruction of the image by default. However, this deployment overrides that with the args setting; manually set the URL to the same value using configuration.
- DOTNETMONITOR_Metrics__Endpoints=http://+:52325
# The image will output logging in a json format by default, which is great for ingestion by tools such as Azure Monitor Log Analytics.
# Switch the logging format to simple for this sample for easier reading.
- Logging__Console__FormatterName=simple
volumes:
- diagvol:/diag
deploy:
resources:
reservations:
cpus: '0.050'
memory: 50M
limits:
cpus: '0.250'
memory: 256M

volumes:
diagvol:
driver_opts:
type: tmpfs
device: tmpfs
```
</details>
## Example Details
* __Listen Mode__: The `dotnet monitor` tool is configured to run in `listen` mode. The tool establishes a diagnostic communication channel at the specified Unix Domain Socket path by the `DOTNETMONITOR_DiagnosticPort__EndpointName` environment variable. The application container has a `DOTNET_DiagnosticPorts` environment variable specified so that the application's runtime will communicate with the `dotnet monitor` instance at the specified Unix Domain Socket path. The application runtime will be suspended (e.g. no managed code execution) until it establishes communication with `dotnet monitor`. Application startup time will depend on how long it takes for the `dotnet monitor` container to run, but this should be quick.
> **7.0+**: Setting `DOTNETMONITOR_DiagnosticPort__EndpointName` is not necessary if (1) `DOTNETMONITOR_Storage__DefaultSharedPath` is set and (2) `DOTNETMONITOR_DiagnosticPort__ConnectionMode` is set to `Listen`; the combination of these settings automatically creates a Unix Domain Socket named `dotnet-monitor.sock` under the default shared path. The `DOTNETMONITOR_DiagnosticPort__EndpointName` setting is still available to use if the default behavior needs to be overridden.
* __Multiple Application Containers__: The `dotnet monitor` tool is capable of monitoring multiple processes at the same time. When running in `listen` mode, each of the applications can connect to the same communication channel path in order to allow `dotnet monitor` to observe them.
* __Dumps Temporary Folder__: The `dotnet monitor` tool is configured to instruct the application runtime to produce dump files at the path specified by the `DOTNETMONITOR_Storage__DumpTempFolder` environment variable. Without specifying this variable, the application runtime will create dump files in the `/tmp` directory of its container, which is not accessible by the `dotnet monitor` container in this example.
> **7.0+**: Setting `DOTNETMONITOR_Storage__DumpTempFolder` is not necessary if `DOTNETMONITOR_Storage__DefaultSharedPath` is set; dumps will be produced in a subfolder under the specified shared path. The `DOTNETMONITOR_Storage__DumpTempFolder` setting is still available to use if the default behavior needs to be overridden.
* __Disabled Authentication__: By default, the `dotnet monitor` tool requires authentication for any of the URLs specified by the `--urls` command line parameter or configured via the `ASPNETCORE_Urls`/`DOTNETMONITOR_Urls` environment variables (see [Authentication](./authentication.md) for further details). For the purposes of this example, authentication has been disabled by using the `--no-auth` command line switch. __Use of this command line switch is NOT recommended for production scenarios__ as it would allow anything with access to the URLs to be able to capture dumps, traces, etc (which may contain sensitive information, such as keys) of any process that `dotnet monitor` is able to monitor.
* __Disabled HTTPS__: By default, the `dotnet monitor` tool has HTTPS enabled on the default artifact URLs, which are configured to be `https://+:52323` in the Docker image. For the purposes of this example, the artifact URLs have been changed to `http://localhost:52323` using the `DOTNETMONITOR_Urls` environment variable such that a TLS certificate is not required. __Disabling HTTPS is NOT recommended for production scenarios.__
* __Command Line Arguments__: Starting in 7.0, the default command line arguments for the `dotnet monitor` tool have been moved to the CMD instruction of the Docker image (previously, they were part of the ENTRYPOINT instruction). If the arguments of the image are overridden, then the default arguments must be explicitly specified in the overridden setting or set via configuration. See [7.0 Compatibility](compatibility/7.0/README.md#docker-container-entrypoint-split) for details.
* __Default Shared Path__: Starting in 7.0, setting the default shared path instructs the `dotnet monitor` tool to automatically share all artifacts (dumps, diagnostic ports, shared libraries, etc) with the target applications in the specified path. This setting simplifies configuration so that a setting for each feature that contains sharable information does not need to necessarily be specified.

## Recommended container limits

The following are the recommended memory and CPU minimums and limits for the `dotnet monitor` container.

```yaml
resources:
reservations:
cpus: '0.050'
memory: 50M
limits:
cpus: '0.250'
memory: 256M
```

How much memory and CPU is consumed by dotnet-monitor is dependent on which scenarios are being executed:
- Metrics consume a negligible amount of resources, although using custom metrics can affect this.
- Operations such as traces and logs may require memory in the main application container that will automatically be allocated by the runtime.
- Resource consumption by trace operations is also dependent on which providers are enabled, as well as the [buffer size](./api/definitions.md#eventprovidersconfiguration) allocated in the runtime.
- It is not recommended to use highly verbose [log levels](./api/definitions.md#loglevel) while under load. This causes a lot of CPU usage in the dotnet-monitor container and more memory pressure in the main application container.
- Dumps also temporarily increase the amount of memory consumed by the application container.
5 changes: 5 additions & 0 deletions documentation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ In addition to its availability as a .NET CLI tool, the `dotnet monitor` tool is
### Nightly Repository
- Docker Hub: https://hub.docker.com/_/microsoft-dotnet-nightly-monitor
- Microsoft Container Registry: https://mcr.microsoft.com/v2/dotnet/nightly/monitor/tags/list

## Sample Usage

- For a Docker Compose sample, see [Running in Docker Compose](./docker-compose.md)
- For a Kubernetes sample, see [Running in Kubernetes](./kubernetes.md)
2 changes: 2 additions & 0 deletions documentation/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ In addition to its availability as a .NET CLI tool, the `dotnet monitor` tool is

For Dockerfiles and repository information, see [Running in Docker](./docker.md)

For a Docker Compose sample, see [Running in Docker Compose](./docker-compose.md)

## Non-root considerations

Starting with .NET 8.0, both the sample ASP.NET application and dotnet-monitor run as non-root. If both the application and dotnet-monitor are 8+, no additional configuration is required. Otherwise, a [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) configuration may need to be added to the application, dotnet-monitor, or both.
Expand Down
7 changes: 7 additions & 0 deletions documentation/releaseNotes/releaseNotes.v9.0.0-rc.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Today we are releasing the official 9.0.0 Release Candidate of the `dotnet monitor` tool. This release includes:

- Updated dependencies



If you would like to provide additional feedback to the team [please fill out this survey](https://aka.ms/dotnet-monitor-survey?src=rn).
2 changes: 1 addition & 1 deletion documentation/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

| Version | Release Date | Latest Version | Runtime Frameworks |
| --- | --- | --- | --- |
| 9.0 | August 13, 2024 | [9.0.0 preview 7](https://github.com/dotnet/dotnet-monitor/releases/tag/v9.0.0-preview.7.24408.4) | net9.0 |
| 9.0 | September 10, 2024 | [9.0.0 rc 1](https://github.com/dotnet/dotnet-monitor/releases/tag/v9.0.0-rc.1.24453.3) | net9.0 |


2 changes: 1 addition & 1 deletion eng/dependabot/independent/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- Third-party references -->
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
<NJsonSchemaVersion>11.0.0</NJsonSchemaVersion>
<SwashbuckleAspNetCoreVersion>6.7.1</SwashbuckleAspNetCoreVersion>
<SwashbuckleAspNetCoreVersion>6.7.3</SwashbuckleAspNetCoreVersion>
<AwsSdkS3Version>3.7.305.7</AwsSdkS3Version>
<AwsSdkSecurityTokenVersion>3.7.300.33</AwsSdkSecurityTokenVersion>

Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/jobs/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
${{ if eq(variables['System.TeamProject'], 'public') }}:
pool:
name: $(DncEngPublicBuildPool)
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open
demands: ImageOverride -equals Build.Ubuntu.2204.Amd64.Open
os: linux

# Official Build Linux Pool
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/stages/preparerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ stages:
- group: Release-Pipeline
steps:
- task: UseDotNet@2
displayName: 'Use .NET 6'
displayName: 'Use .NET 8'
inputs:
packageType: runtime
version: 6.x
version: 8.x
installationPath: '$(Build.Repository.LocalPath)\.dotnet'

- script: mkdir $(System.ArtifactsDirectory)\StagingToolLogs
Expand Down
16 changes: 8 additions & 8 deletions eng/release/DiagnosticsReleaseTool/DiagnosticsReleaseTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>

Expand All @@ -13,15 +13,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="[6.0.0]" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="[6.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[6.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="[6.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="[6.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[6.0.0]" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="[8.0.0]" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[8.0.0]" />

<PackageReference Include="Azure.Identity" Version="[1.12.0]" />
<PackageReference Include="Azure.Storage.Blobs" Version="[12.20.0]" />
<PackageReference Include="Azure.Storage.Blobs" Version="[12.21.2]" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20468.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public void ExceptionGroup(
public void ExceptionInstance(
ulong ExceptionId,
ulong ExceptionGroupId,
string? ExceptionMessage,
string ExceptionMessage,
ulong[] StackFrameIds,
DateTime Timestamp,
ulong[] InnerExceptionIds,
string? ActivityId,
string ActivityId,
ActivityIdFormat ActivityIdFormat)
{
Span<EventData> data = stackalloc EventData[8];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Invoke(Exception exception, ExceptionPipelineExceptionContext contex
frameIds,
context.Timestamp,
GetInnerExceptionsIds(exception),
context.ActivityId,
context.ActivityId ?? string.Empty,
context.ActivityIdFormat
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal interface IExceptionInstance

ulong[] InnerExceptionIds { get; }

public string? ActivityId { get; }
public string ActivityId { get; }

public ActivityIdFormat ActivityIdFormat { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void ExceptionsEventSource_WriteException_LevelTooHigh()
using ExceptionsEventListener listener = new();
listener.EnableEvents(source, EventLevel.Warning);

source.ExceptionInstance(5, 7, ObjectDisposedExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), null, ActivityIdFormat.Unknown);
source.ExceptionInstance(5, 7, ObjectDisposedExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), string.Empty, ActivityIdFormat.Unknown);

Assert.Empty(listener.Exceptions);
}
Expand All @@ -123,7 +123,7 @@ public void ExceptionsEventSource_WriteException_NotEnabled()

using ExceptionsEventListener listener = new();

source.ExceptionInstance(7, 9, OperationCancelledExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), null, ActivityIdFormat.Unknown);
source.ExceptionInstance(7, 9, OperationCancelledExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), string.Empty, ActivityIdFormat.Unknown);

Assert.Empty(listener.Exceptions);
}
Expand Down

0 comments on commit dca8904

Please sign in to comment.