-
-
Notifications
You must be signed in to change notification settings - Fork 230
WIP: Logs pre-release #4340
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
Closed
Closed
WIP: Logs pre-release #4340
Changes from all commits
Commits
Show all changes
134 commits
Select commit
Hold shift + click to select a range
0add668
feat(logs): initial experiment
Flash0ver db7d558
feat(logs): basic Logger Module API shape
Flash0ver d96b092
style(logs): consolidate
Flash0ver 2958a47
ref(logs): remove generic WriteSerializable overload
Flash0ver a63371b
ref(logs): consolidate experimental Diagnostic-ID
Flash0ver d8d2567
feat(logs): add experimental options
Flash0ver fefd24c
Merge branch 'main' into feat/logs-initial-api
Flash0ver 165996a
ref(logs): remove custom polyfills now provided through Polyfill
Flash0ver 32e7e25
Format code
getsentry-bot fc88722
Merge branch 'feat/logs-initial-api' of https://github.com/getsentry/…
Flash0ver 2ba87e4
ref(logs): move types out of Experimental namespace
Flash0ver 0f1d4a4
feat(logs): change 'integer' from Int32 to Int64
Flash0ver 8dec5d5
ref(logs): refine API surface area
Flash0ver a664f7e
ref(logs): match SeverityLevel to OTel spec
Flash0ver 96693d0
ref(logs): rename SentrySeverity to LogSeverityLevel
Flash0ver 83964cf
Format code
getsentry-bot dadc69b
ref(logs): hide underlying Dictionary`2 for Attributes
Flash0ver c91cdde
ref(logs): restructure attributes
Flash0ver 0740c3b
ref(logs): extract TraceId and ParentSpanId methods
Flash0ver eee06bf
ref(logs): remove `SentryOptions.LogsSampleRate`
Flash0ver 8c61d8b
feat(logs): support ISystemClock abstraction
Flash0ver 80683ae
ref(logs): disambiguate SentryLogger names
Flash0ver cb20118
ref(logs): consolidate names of Log-Methods
Flash0ver 2cb306f
ref(logs): rename LogSeverityLevel to SentryLogLevel
Flash0ver dcc0ec1
ref(logs): re-rename new logger type
Flash0ver 58dce74
ref(logs): move Logger instances to Hubs
Flash0ver f2e1ba2
test(logs): add tests
Flash0ver 0220015
Merge branch 'main' into feat/logs-initial-api
Flash0ver 6822b23
Format code
getsentry-bot dd39fae
fix(logs): incorrectly serializing attributes
Flash0ver 6eb5b9b
fix(logs): do not capture log when template/parameters are invalid
Flash0ver 69c05b8
fix(logs): do not capture log on user callback exceptions
Flash0ver 430cf82
ref(logs): move new public types to root namespace
Flash0ver 31a8f1f
ref(logs): rework sample
Flash0ver 2ae4476
ref(logs): ensure that DisabledHub dues not capture logs
Flash0ver 69678ce
ref(logs): allow out-of-range Log-Level
Flash0ver 97995a8
docs(logs): add XML comments indicating that logs will be ignored on …
Flash0ver fbe747d
docs(logs): add to changelog
Flash0ver 64adf33
fix(logs): add to Bindable-Options
Flash0ver cdfa901
fix(logs): add to ApiApprovalTests
Flash0ver d2ac53b
test(logs): add missing net48 ApiApproval
Flash0ver 4011ba6
test(logs): fix line endings on Windows
Flash0ver 4ae82d0
Update src/Sentry/Protocol/Envelopes/Envelope.cs
Flash0ver bc1c465
Update SentryLog.cs
Flash0ver 79fb190
test(logs): fix floating-point ToString expectation for .NET Framework
Flash0ver b4e80f4
ref(logs): remove some using declarations
Flash0ver b21adef
test(ci): trying to work around floating-point formatter on .NET Fram…
Flash0ver 0032858
test(logs): skip failing tests on Mono (non-Windows)
Flash0ver a9769f8
test(log): fix Skip.If missing SkippableFact
Flash0ver 9a51033
try: fix floating-point formatting on Windows
Flash0ver 8d03449
feat(logs): Sentry.Extensions.Logging
Flash0ver 1bc3a6f
feat(logs): Sentry.AspNetCore
Flash0ver 7624baa
feat(logs): Sentry.Maui
Flash0ver 11fe02b
fix(logs): Logging Filter
Flash0ver fd532ca
Format code
getsentry-bot 1fe9cc0
feat(logs): add CHANGELOG entry
Flash0ver 476cbc3
Merge branch 'feat/logs-microsoft-extensions-logging' of https://gith…
Flash0ver 9a09832
Merge branch 'main' into feat/logs-initial-api
Flash0ver d9ce523
Merge branch 'main' into feat/logs-microsoft-extensions-logging
Flash0ver 3e6dba5
release: 5.8.0-alpha.0
getsentry-bot 23934dc
Merge branch 'release/5.8.0-alpha.0' into feat/logs-microsoft-extensi…
f133118
Merge branch 'main' into feat/logs-initial-api
Flash0ver 0985a76
Merge branch 'main' into feat/logs-microsoft-extensions-logging
Flash0ver 72c9a93
ref: make SentryStructuredLogger abstract
Flash0ver c97f4ad
docs: add comment to sample usage of SetBeforeSendLog
Flash0ver a9eea90
ref: clarify intent of usages of Debug.Assert
Flash0ver 8bd0ed2
docs: improve XML comments
Flash0ver 51892de
test: range of Severity-Number specification
Flash0ver acc8995
test: GetValuesAsUnderlyingType of the new enum
Flash0ver 6bd4c96
ref: move Log options to Experimental section
Flash0ver f673d1e
ref: move Logger to Experimental section of SDK
Flash0ver daafd7f
test: add Hub tests
Flash0ver 62ee5d5
Merge branch 'feat/logs' into feat/logs-initial-api
Flash0ver 6a54203
test: update verified public API
Flash0ver 479cab8
docs: update CHANGELOG.md
Flash0ver f59160b
Merge branch 'feat/logs-initial-api' into feat/logs-microsoft-extensi…
Flash0ver 18a8284
ref: move Log-rerelated Options to Experimental sub-section
Flash0ver 97a87f8
Merge branch 'main' into feat/logs-initial-api
jamescrosswell 0467449
Merge branch 'feat/logs' into feat/logs-initial-api
Flash0ver 54062d2
ref: reuse Disabled-Instance when Structured-Logging is not enabled
Flash0ver 7107bce
ref: remove Enabled-checks on Default-Logger
Flash0ver c0a1cd5
ref: rename DisabledSentryStructuredLogger to NoOpSentryStructuredLogger
Flash0ver 45b8687
ref: make `BindableSentryOptions.Experimental` internal
Flash0ver 3192534
Revert "ref: make `BindableSentryOptions.Experimental` internal"
Flash0ver b8bcea6
docs: Update CHANGELOG.md
Flash0ver d4c82a2
Revert "ref: rename DisabledSentryStructuredLogger to NoOpSentryStruc…
Flash0ver 9193a96
ref: replace use of ScopeManager with TraceHeader
Flash0ver 7cb4043
test: remove Skip as we no longer test net48 against non-Windows
Flash0ver e3ca5b5
feat: support more numeric types
Flash0ver afb135e
feat: support char attributes
Flash0ver 7f675aa
fix: build error targeting .NET Standard 2.0 and .NET Framework
Flash0ver 750a388
fix: exception when passing null as message parameter
Flash0ver 9f62d3b
test: add Attributes-To-Json test
Flash0ver 5b00c21
fix: missing type on .NET Framework
Flash0ver 6d17918
feat: support Attribute-Types from spec
Flash0ver 7e2c57b
ref: clarify internal identifiers
Flash0ver 7115c42
test: update approved API
Flash0ver cd5246b
test: fix incorrect expectation
Flash0ver baf5569
Merge branch 'feat/logs' into feat/logs-initial-api
Flash0ver e592d03
Merge branch 'feat/logs-initial-api' into feat/logs-microsoft-extensi…
Flash0ver 6e13e95
feat: use "wrapping" SDK's Name and Version
Flash0ver 0a9a3b1
fix: Get-Attribute-API
Flash0ver 934fb36
Merge branch 'feat/logs' into feat/logs-initial-api
Flash0ver 2c1608e
docs: update CHANGELOG
Flash0ver 2b09a79
Merge branch 'feat/logs-initial-api' into feat/logs-microsoft-extensi…
Flash0ver 2950be9
docs: update CHANGELOG
Flash0ver 8d35362
feat(logs): initial API for Sentry Logs (#4158)
Flash0ver d24d165
feat: add Batch Processor for Logs
Flash0ver aad0599
test: Batch Processor for Logs
Flash0ver 76fcc1b
docs: Batch Processor for Logs
Flash0ver 2ad33f6
test: fix unavailable API on TargetFramework=net48
Flash0ver 38e1c04
test: run all Logs tests on full framework
Flash0ver f7a43b8
ref: remove usage of System.Threading.Lock
Flash0ver e6b0b74
ref: rename members for clarity
Flash0ver f5b5971
Merge branch 'main' into feat/logs
Flash0ver a84b78f
Merge branch 'feat/logs' into feat/logs-buffering
Flash0ver 53c90ea
ref: delete Timer-Abstraction and change to System.Threading.Timer
Flash0ver 6580632
ref: delete .ctor only called from tests
Flash0ver 6e2ee9b
ref: switch Buffer-Processor to be lock-free but discarding
Flash0ver 0774709
test: fix BatchBuffer and Tests
Flash0ver d9ae794
fix: flushing buffer on Timeout
Flash0ver 7e1f5ea
feat: add Backpressure-ClientReport
Flash0ver 365a2fb
ref: make BatchProcessor more resilient
Flash0ver 8b1f716
Merge branch 'main' into feat/logs
Flash0ver c478391
Format code
getsentry-bot eeae2ab
Merge branch 'main' into feat/logs
Flash0ver 211beea
Merge branch 'feat/logs' into feat/logs-buffering
Flash0ver d428163
Merge branch 'feat/logs' into feat/logs-microsoft-extensions-logging
Flash0ver a936ec6
test: change options to Experimental section
Flash0ver c699c2d
test: fix on .NET Framework
Flash0ver ca00162
Merge branch 'feat/logs-microsoft-extensions-logging' into feat/logs-…
Flash0ver ec7772f
ci: disable iOS Device Tests
Flash0ver 15cc89c
release: 5.12.0-alpha.0
getsentry-bot 305aee4
Merge branch 'release/5.12.0-alpha.0' into feat/logs-pre-release
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 hidden or 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 |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ on: | |
|
|
||
| jobs: | ||
| ios-tests: | ||
| if: false | ||
| runs-on: macos-15 | ||
| env: | ||
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
18 changes: 18 additions & 0 deletions
18
src/Sentry.AspNetCore/SentryAspNetCoreStructuredLoggerProvider.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Options; | ||
| using Sentry.Extensions.Logging; | ||
|
|
||
| namespace Sentry.AspNetCore; | ||
|
|
||
| /// <summary> | ||
| /// Structured Logger Provider for Sentry. | ||
| /// </summary> | ||
| [ProviderAlias("SentryLogs")] | ||
| [Experimental(Infrastructure.DiagnosticId.ExperimentalFeature)] | ||
| internal sealed class SentryAspNetCoreStructuredLoggerProvider : SentryStructuredLoggerProvider | ||
| { | ||
| public SentryAspNetCoreStructuredLoggerProvider(IOptions<SentryAspNetCoreOptions> options, IHub hub) | ||
| : base(options, hub) | ||
| { | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Sentry.Extensions.Logging; | ||
|
|
||
| [Experimental(Infrastructure.DiagnosticId.ExperimentalFeature)] | ||
| internal sealed class SentryStructuredLogger : ILogger | ||
| { | ||
| private readonly string _categoryName; | ||
| private readonly SentryLoggingOptions _options; | ||
| private readonly IHub _hub; | ||
|
|
||
| internal SentryStructuredLogger(string categoryName, SentryLoggingOptions options, IHub hub) | ||
| { | ||
| _categoryName = categoryName; | ||
| _options = options; | ||
| _hub = hub; | ||
| } | ||
|
|
||
| public IDisposable? BeginScope<TState>(TState state) where TState : notnull | ||
| { | ||
| return NullDisposable.Instance; | ||
| } | ||
|
|
||
| public bool IsEnabled(LogLevel logLevel) | ||
| { | ||
| return _hub.IsEnabled | ||
| && _options.Experimental.EnableLogs | ||
| && logLevel != LogLevel.None | ||
| && logLevel >= _options.ExperimentalLogging.MinimumLogLevel; | ||
| } | ||
|
|
||
| public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) | ||
| { | ||
| if (!IsEnabled(logLevel)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // not quite ideal as this is a boxing allocation from Microsoft.Extensions.Logging.FormattedLogValues | ||
| /* | ||
| string? template = null; | ||
| object[]? parameters = null; | ||
| if (state is IReadOnlyList<KeyValuePair<string, object?>> formattedLogValues) | ||
| { | ||
| foreach (var formattedLogValue in formattedLogValues) | ||
| { | ||
| if (formattedLogValue.Key == "{OriginalFormat}" && formattedLogValue.Value is string formattedString) | ||
| { | ||
| template = formattedString; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| */ | ||
|
|
||
| string message = formatter.Invoke(state, exception); | ||
|
|
||
| switch (logLevel) | ||
| { | ||
| case LogLevel.Trace: | ||
| _hub.Logger.LogTrace(message); | ||
| break; | ||
| case LogLevel.Debug: | ||
| _hub.Logger.LogDebug(message); | ||
| break; | ||
| case LogLevel.Information: | ||
| _hub.Logger.LogInfo(message); | ||
| break; | ||
| case LogLevel.Warning: | ||
| _hub.Logger.LogWarning(message); | ||
| break; | ||
| case LogLevel.Error: | ||
| _hub.Logger.LogError(message); | ||
| break; | ||
| case LogLevel.Critical: | ||
| _hub.Logger.LogFatal(message); | ||
| break; | ||
| case LogLevel.None: | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| file sealed class NullDisposable : IDisposable | ||
| { | ||
| public static NullDisposable Instance { get; } = new NullDisposable(); | ||
|
|
||
| private NullDisposable() | ||
| { | ||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| } | ||
| } |
Oops, something went wrong.
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.
TODO: figure out why device tests on iOS are failing, it's unrelated to logs.
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.
We should be able to merge from main and revert this line now.