getsentry / getsentry/sentry-dotnet

feat: support `BeginScope` of `Microsoft.Extensions.Logging` for Structured Logs

Open
#5,222 4 comments 1 reaction 0 assignees View on GitHub
.NET Explore > Logs Feature Logs Microsoft.Extensions.Logging Next Major
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

### Description

### Summary

Attach _state_
and `FormattedLogValues` (`IReadOnlyList>` or `IEnumerable>`)
provided via the `IDisposable`-returning `BeginScope` (instance and extension) methods
as Attributes to Logs.

### Remarks

APIs to support
- [IDisposable? Microsoft.Extensions.Logging.ILogger.BeginScope(TState state) where TState : notnull](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger.beginscope)
- [IDisposable? Microsoft.Extensions.Logging.LoggerExtensions.BeginScope(this ILogger logger, string messageFormat, params object?[] args)](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.loggerextensions.beginscope)

Consider using `Microsoft.Extensions.Logging.IExternalScopeProvider` as implementation detail.

Consider supporting a boolean `IncludeScopes` option, that e.g. the `Console`-Logger exposes.

See docs at [Logging in C# and .NET > Log scopes](https://learn.microsoft.com/dotnet/core/extensions/logging/overview#log-scopes).

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.