Skip to content

Commit d3d2f71

Browse files
authored
ref(logs): make API stable (remove Experimental from Options) (#4699)
1 parent 19a8c1a commit d3d2f71

File tree

37 files changed

+112
-175
lines changed

37 files changed

+112
-175
lines changed

benchmarks/Sentry.Benchmarks/Extensions.Logging/SentryStructuredLoggerBenchmarks.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ public void Setup()
2222
SentryLoggingOptions options = new()
2323
{
2424
Dsn = DsnSamples.ValidDsn,
25-
Experimental =
26-
{
27-
EnableLogs = true,
28-
},
25+
EnableLogs = true,
2926
ExperimentalLogging =
3027
{
3128
MinimumLogLevel = LogLevel.Information,
3229
}
3330
};
34-
options.Experimental.SetBeforeSendLog((SentryLog log) =>
31+
options.SetBeforeSendLog((SentryLog log) =>
3532
{
3633
_lastLog = log;
3734
return null;

benchmarks/Sentry.Benchmarks/StructuredLogBatchProcessorBenchmarks.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ public void Setup()
2222
SentryOptions options = new()
2323
{
2424
Dsn = DsnSamples.ValidDsn,
25-
Experimental =
26-
{
27-
EnableLogs = true,
28-
},
25+
EnableLogs = true,
2926
};
3027

3128
var batchInterval = Timeout.InfiniteTimeSpan;

samples/Sentry.Samples.AspNetCore.Basic/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#endif
1818

1919
// This option enables Logs sent to Sentry.
20-
options.Experimental.EnableLogs = true;
20+
options.EnableLogs = true;
2121
});
2222

2323
var app = builder.Build();

samples/Sentry.Samples.Console.Basic/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
options.TracesSampleRate = 1.0;
3939

4040
// This option enables Sentry Logs created via SentrySdk.Logger.
41-
options.Experimental.EnableLogs = true;
42-
options.Experimental.SetBeforeSendLog(static log =>
41+
options.EnableLogs = true;
42+
options.SetBeforeSendLog(static log =>
4343
{
4444
// A demonstration of how you can drop logs based on some attribute they have
4545
if (log.TryGetAttribute("suppress", out var attribute) && attribute is true)

samples/Sentry.Samples.ME.Logging/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
options.ExperimentalLogging.MinimumLogLevel = LogLevel.Trace; // This level or above will result in log sent to Sentry
2727

2828
// This option enables Logs sent to Sentry.
29-
options.Experimental.EnableLogs = true;
30-
options.Experimental.SetBeforeSendLog(static log =>
29+
options.EnableLogs = true;
30+
options.SetBeforeSendLog(static log =>
3131
{
3232
log.SetAttribute("attribute-key", "attribute-value");
3333
return log;

samples/Sentry.Samples.Maui/MauiProgram.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static MauiApp CreateMauiApp()
3333
options.AttachScreenshot = true;
3434

3535
options.Debug = true;
36-
options.Experimental.EnableLogs = true;
36+
options.EnableLogs = true;
3737
options.SampleRate = 1.0F;
3838

3939
// The Sentry MVVM Community Toolkit integration automatically creates traces for async relay commands,

samples/Sentry.Samples.Serilog/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private static void Main()
2626
options.MinimumEventLevel = LogEventLevel.Error;
2727
options.AttachStacktrace = true;
2828
// send structured logs to Sentry
29-
options.Experimental.EnableLogs = true;
29+
options.EnableLogs = true;
3030
// send PII like the username of the user logged in to the device
3131
options.SendDefaultPii = true;
3232
// Optional Serilog text formatter used to format LogEvent to string. If TextFormatter is set, FormatProvider is ignored.

src/Sentry.Extensions.Logging/SentryStructuredLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal SentryStructuredLogger(string categoryName, SentryLoggingOptions option
2929
public bool IsEnabled(LogLevel logLevel)
3030
{
3131
return _hub.IsEnabled
32-
&& _options.Experimental.EnableLogs
32+
&& _options.EnableLogs
3333
&& logLevel != LogLevel.None
3434
&& logLevel >= _options.ExperimentalLogging.MinimumLogLevel;
3535
}

src/Sentry.Serilog/SentrySink.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private bool IsEnabled(LogEvent logEvent)
8484

8585
return logEvent.Level >= _options.MinimumEventLevel
8686
|| logEvent.Level >= _options.MinimumBreadcrumbLevel
87-
|| options?.Experimental.EnableLogs is true;
87+
|| options?.EnableLogs is true;
8888
}
8989

9090
private void InnerEmit(LogEvent logEvent)
@@ -169,7 +169,7 @@ private void InnerEmit(LogEvent logEvent)
169169
// In cases where Sentry's Serilog-Sink is added without a DSN (i.e., without initializing the SDK) and the SDK is initialized differently (e.g., through ASP.NET Core),
170170
// then the 'EnableLogs' option of this Sink's Serilog-Options is default, but the Hub's Sentry-Options have the actual user-defined value configured.
171171
var options = hub.GetSentryOptions();
172-
if (options?.Experimental.EnableLogs is true)
172+
if (options?.EnableLogs is true)
173173
{
174174
CaptureStructuredLog(hub, options, logEvent, formatted, template);
175175
}

src/Sentry.Serilog/SentrySinkExtensions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static class SentrySinkExtensions
3535
/// <param name="reportAssembliesMode">What mode to use for reporting referenced assemblies in each event sent to sentry. Defaults to <see cref="Sentry.ReportAssembliesMode.Version"/></param>
3636
/// <param name="deduplicateMode">What modes to use for event automatic de-duplication. <seealso cref="SentryOptions.DeduplicateMode"/></param>
3737
/// <param name="defaultTags">Default tags to add to all events. <seealso cref="SentryOptions.DefaultTags"/></param>
38-
/// <param name="experimentalEnableLogs">Whether to send structured logs. <seealso cref="SentryOptions.SentryExperimentalOptions.EnableLogs"/></param>
38+
/// <param name="enableLogs">Whether to send structured logs. <seealso cref="SentryOptions.EnableLogs"/></param>
3939
/// <returns><see cref="LoggerConfiguration"/></returns>
4040
/// <example>This sample shows how each item may be set from within a configuration file:
4141
/// <code>
@@ -73,7 +73,7 @@ public static class SentrySinkExtensions
7373
/// "key-1", "value-1",
7474
/// "key-2", "value-2"
7575
/// },
76-
/// "experimentalEnableLogs": true
76+
/// "enableLogs": true
7777
/// }
7878
/// }
7979
/// ]
@@ -106,7 +106,7 @@ public static LoggerConfiguration Sentry(
106106
ReportAssembliesMode? reportAssembliesMode = null,
107107
DeduplicateMode? deduplicateMode = null,
108108
Dictionary<string, string>? defaultTags = null,
109-
bool? experimentalEnableLogs = null)
109+
bool? enableLogs = null)
110110
{
111111
return loggerConfiguration.Sentry(o => ConfigureSentrySerilogOptions(o,
112112
dsn,
@@ -132,7 +132,7 @@ public static LoggerConfiguration Sentry(
132132
reportAssembliesMode,
133133
deduplicateMode,
134134
defaultTags,
135-
experimentalEnableLogs));
135+
enableLogs));
136136
}
137137

138138
/// <summary>
@@ -210,7 +210,7 @@ internal static void ConfigureSentrySerilogOptions(
210210
ReportAssembliesMode? reportAssembliesMode = null,
211211
DeduplicateMode? deduplicateMode = null,
212212
Dictionary<string, string>? defaultTags = null,
213-
bool? experimentalEnableLogs = null)
213+
bool? enableLogs = null)
214214
{
215215
if (dsn is not null)
216216
{
@@ -322,9 +322,9 @@ internal static void ConfigureSentrySerilogOptions(
322322
sentrySerilogOptions.DeduplicateMode = deduplicateMode.Value;
323323
}
324324

325-
if (experimentalEnableLogs.HasValue)
325+
if (enableLogs.HasValue)
326326
{
327-
sentrySerilogOptions.Experimental.EnableLogs = experimentalEnableLogs.Value;
327+
sentrySerilogOptions.EnableLogs = enableLogs.Value;
328328
}
329329

330330
// Serilog-specific items

0 commit comments

Comments
 (0)