getsentry / getsentry/sentry-dotnet

server.address is missing from Structured Logs

Open
#4,493 2 comments 0 reactions 1 assignee Claimed by @Flash0ver View on GitHub
.NET Bug Logs
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

### Package

Sentry.AspNetCore

### .NET Flavor

.NET Core

### .NET Version

8.0.413

### OS

Windows

### OS Version

Windows 11 Enterprise 24H2

### Development Environment

Visual Studio Code (Windows)

### SDK Version

5.14.1

### Self-Hosted Sentry Version

_No response_

### Workload Versions

```
dotnet workload list

Installed Workload Id Manifest Version Installation Source
--------------------------------------------------------------------

Use `dotnet workload search` to find additional workloads to install.
```

### UseSentry or SentrySdk.Init call

I just call `builder.WebHost.UseSentry()` in Program.cs.

### Steps to Reproduce

1. Create an ASP.NET Core hello world app
2. Run `dotnet add package Sentry.AspNetCore`
3. Edit appsettings.json as below
4. Include this in Program.cs: `builder.WebHost.UseSentry();`

```json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
},
"File": {
"Path": null
}
},
"Sentry": {
"Dsn": "https://xxx@xxx.ingest.us.sentry.io/xxx",
"SendDefaultPii": true,
"MaxRequestBodySize": "Always",
"MinimumBreadcrumbLevel": "Debug",
"MinimumEventLevel": "Debug",
"AttachStackTrace": true,
"Debug": true,
"DiagnosticLevel": "Error",
"TracesSampleRate": 1.0,
"Experimental": {
"EnableLogs": true
}
}
}
```

### Expected Result

https://docs.sentry.io/platforms/dotnet/guides/extensions-logging/logs/#server-attributes says there shall be a server.address attribute in Logs. There doesn't seem to be. I expected something like this where the server.address is present.

```json
{
"payload_size": "577",
"project_id": "xxx",
"tags[microsoft.extensions.logging.event.id,number]": "2",
"timestamp_precise": "1756899350742000000",
"environment": "development",
"message": "Connection id \"0HNFARN182IEO\" stopped.",
"message.parameter.ConnectionId": "0HNFARN182IEO",
"message.template": "Connection id \"{ConnectionId}\" stopped.",
"microsoft.extensions.logging.category_name": "Microsoft.AspNetCore.Server.Kestrel.Connections",
"microsoft.extensions.logging.event.name": "ConnectionStop",
"release": "xxx@1.0.0.0-dev+xxx",
"sdk.name": "sentry.dotnet.aspnetcore",
"sdk.version": "5.14.1",
"server.address": "Foo",
"severity": "debug",
"trace": "ad624f73866444b9a0f18424e4e0e64f",
"trace.parent_span_id": "60d35e983820623a",
"id": "dbfc4db54fe883ac1871d6985c0f9901",
"observed_timestamp_nanos": "1756899355847905746"
}
```

### Actual Result

I get this, notice server.address is *not* present:

```json
{
"payload_size": "577",
"project_id": "xxx",
"tags[microsoft.extensions.logging.event.id,number]": "2",
"timestamp_precise": "1756899350742000000",
"environment": "development",
"message": "Connection id \"0HNFARN182IEO\" stopped.",
"message.parameter.ConnectionId": "0HNFARN182IEO",
"message.template": "Connection id \"{ConnectionId}\" stopped.",
"microsoft.extensions.logging.category_name": "Microsoft.AspNetCore.Server.Kestrel.Connections",
"microsoft.extensions.logging.event.name": "ConnectionStop",
"release": "xxx@1.0.0.0-dev+xxx",
"sdk.name": "sentry.dotnet.aspnetcore",
"sdk.version": "5.14.1",
"severity": "debug",
"trace": "ad624f73866444b9a0f18424e4e0e64f",
"trace.parent_span_id": "60d35e983820623a",
"id": "dbfc4db54fe883ac1871d6985c0f9901",
"observed_timestamp_nanos": "1756899355847905746"
}
```

I can put a server.address attribute there by changing my call to `UseSentry` like this:

```csharp
builder.WebHost.UseSentry(o =>
{
o.Experimental.SetBeforeSendLog(static log =>
{
log.SetAttribute("server.address", Environment.MachineName);
return log;
});
});
```

Having to do this is not consistent with the documentation at https://docs.sentry.io/platforms/dotnet/guides/extensions-logging/logs/#server-attributes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.