diff --git a/CHANGELOG.md b/CHANGELOG.md index 3738ec4529..270fb60358 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- GA release for Sentry Metrics ([#5023](https://github.com/getsentry/sentry-dotnet/pull/5023)) + ## 6.2.0 ### Features diff --git a/Directory.Build.props b/Directory.Build.props index 221a7b4085..137e290ef3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,7 +13,6 @@ $(NoWarn);SENTRY0001 - $(NoWarn);SENTRYTRACECONNECTEDMETRICS $(NoWarn);CS8002 diff --git a/samples/Sentry.Samples.Console.Basic/Program.cs b/samples/Sentry.Samples.Console.Basic/Program.cs index 92ddd4e09f..0603caab27 100644 --- a/samples/Sentry.Samples.Console.Basic/Program.cs +++ b/samples/Sentry.Samples.Console.Basic/Program.cs @@ -54,8 +54,8 @@ return log.Level is SentryLogLevel.Info ? null : log; }); - // Sentry (trace-connected) Metrics via SentrySdk.Experimental.Metrics are enabled by default. - options.Experimental.SetBeforeSendMetric(static metric => + // Sentry (trace-connected) Metrics via SentrySdk.Metrics are enabled by default. + options.SetBeforeSendMetric(static metric => { if (metric.TryGetValue(out int integer) && integer < 0) { @@ -104,13 +104,13 @@ async Task FirstFunction() SentrySdk.Logger.LogInfo("HTTP Request completed."); // Counter-Metric prevented from being sent to Sentry via "BeforeSendMetric" callback - SentrySdk.Experimental.Metrics.EmitCounter("sentry.samples.console.basic.ignore", -1); + SentrySdk.Metrics.EmitCounter("sentry.samples.console.basic.ignore", -1); // Counter-Metric modified before sending it to Sentry via "BeforeSendMetric" callback - SentrySdk.Experimental.Metrics.EmitCounter("sentry.samples.console.basic.http_requests_completed", 1); + SentrySdk.Metrics.EmitCounter("sentry.samples.console.basic.http_requests_completed", 1); // Distribution-Metric sent as is (see "BeforeSendMetric" callback) - SentrySdk.Experimental.Metrics.EmitDistribution("sentry.samples.console.basic.http_request_duration", stopwatch.Elapsed.TotalSeconds, MeasurementUnit.Duration.Second, + SentrySdk.Metrics.EmitDistribution("sentry.samples.console.basic.http_request_duration", stopwatch.Elapsed.TotalSeconds, MeasurementUnit.Duration.Second, [new KeyValuePair("http.request.method", HttpMethod.Get.Method), new KeyValuePair("http.response.status_code", (int)HttpStatusCode.OK)]); } diff --git a/src/Sentry/BindableSentryOptions.cs b/src/Sentry/BindableSentryOptions.cs index 52abdf7df9..ebfba5c55a 100644 --- a/src/Sentry/BindableSentryOptions.cs +++ b/src/Sentry/BindableSentryOptions.cs @@ -22,6 +22,7 @@ internal partial class BindableSentryOptions public string? Environment { get; set; } public string? Dsn { get; set; } public bool? EnableLogs { get; set; } + public bool? EnableMetrics { get; set; } public int? MaxQueueItems { get; set; } public int? MaxCacheItems { get; set; } public TimeSpan? ShutdownTimeout { get; set; } @@ -56,8 +57,6 @@ internal partial class BindableSentryOptions public bool? EnableSpotlight { get; set; } public string? SpotlightUrl { get; set; } - public ExperimentalSentryOptions? Experimental { get; set; } - public void ApplyTo(SentryOptions options) { options.IsGlobalModeEnabled = IsGlobalModeEnabled ?? options.IsGlobalModeEnabled; @@ -75,6 +74,7 @@ public void ApplyTo(SentryOptions options) options.Environment = Environment ?? options.Environment; options.Dsn = Dsn ?? options.Dsn; options.EnableLogs = EnableLogs ?? options.EnableLogs; + options.EnableMetrics = EnableMetrics ?? options.EnableMetrics; options.MaxQueueItems = MaxQueueItems ?? options.MaxQueueItems; options.MaxCacheItems = MaxCacheItems ?? options.MaxCacheItems; options.ShutdownTimeout = ShutdownTimeout ?? options.ShutdownTimeout; @@ -108,11 +108,6 @@ public void ApplyTo(SentryOptions options) options.EnableSpotlight = EnableSpotlight ?? options.EnableSpotlight; options.SpotlightUrl = SpotlightUrl ?? options.SpotlightUrl; - if (Experimental is { } experimental) - { - options.Experimental.EnableMetrics = experimental.EnableMetrics ?? options.Experimental.EnableMetrics; - } - #if ANDROID Android.ApplyTo(options.Android); Native.ApplyTo(options.Native); @@ -120,12 +115,4 @@ public void ApplyTo(SentryOptions options) Native.ApplyTo(options.Native); #endif } - - /// - /// Bindable Options for . - /// - internal class ExperimentalSentryOptions - { - public bool? EnableMetrics { get; set; } - } } diff --git a/src/Sentry/Extensibility/DisabledHub.cs b/src/Sentry/Extensibility/DisabledHub.cs index 03f70ff591..9bf79277f0 100644 --- a/src/Sentry/Extensibility/DisabledHub.cs +++ b/src/Sentry/Extensibility/DisabledHub.cs @@ -270,6 +270,5 @@ public void Dispose() /// /// Disabled Metrics. /// - [Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat = "https://github.com/getsentry/sentry-dotnet/discussions/4838")] public SentryMetricEmitter Metrics => DisabledSentryMetricEmitter.Instance; } diff --git a/src/Sentry/Extensibility/HubAdapter.cs b/src/Sentry/Extensibility/HubAdapter.cs index 2db6900259..055498c2fc 100644 --- a/src/Sentry/Extensibility/HubAdapter.cs +++ b/src/Sentry/Extensibility/HubAdapter.cs @@ -39,8 +39,7 @@ private HubAdapter() { } /// /// Forwards the call to . /// - [Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat = "https://github.com/getsentry/sentry-dotnet/discussions/4838")] - public SentryMetricEmitter Metrics { [DebuggerStepThrough] get => SentrySdk.Experimental.Metrics; } + public SentryMetricEmitter Metrics { [DebuggerStepThrough] get => SentrySdk.Metrics; } /// /// Forwards the call to . diff --git a/src/Sentry/IHub.cs b/src/Sentry/IHub.cs index a5a7afd9c9..7831616152 100644 --- a/src/Sentry/IHub.cs +++ b/src/Sentry/IHub.cs @@ -35,11 +35,10 @@ public interface IHub : ISentryClient, ISentryScopeManager /// /// Available options: /// - /// - /// + /// + /// /// /// - [Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat = "https://github.com/getsentry/sentry-dotnet/discussions/4838")] public SentryMetricEmitter Metrics { get; } /// diff --git a/src/Sentry/Internal/DefaultSentryMetricEmitter.cs b/src/Sentry/Internal/DefaultSentryMetricEmitter.cs index b8e25964ca..1b798b49b1 100644 --- a/src/Sentry/Internal/DefaultSentryMetricEmitter.cs +++ b/src/Sentry/Internal/DefaultSentryMetricEmitter.cs @@ -14,7 +14,7 @@ internal sealed class DefaultSentryMetricEmitter : SentryMetricEmitter, IDisposa internal DefaultSentryMetricEmitter(IHub hub, SentryOptions options, ISystemClock clock, int batchCount, TimeSpan batchInterval) { Debug.Assert(hub.IsEnabled); - Debug.Assert(options.Experimental is { EnableMetrics: true }); + Debug.Assert(options is { EnableMetrics: true }); _hub = hub; _options = options; @@ -69,7 +69,7 @@ private protected override void CaptureMetric(SentryMetric metric) where T SentryMetric? configuredMetric = metric; - if (_options.Experimental.BeforeSendMetricInternal is { } beforeSendMetric) + if (_options.BeforeSendMetricInternal is { } beforeSendMetric) { try { diff --git a/src/Sentry/SentryMetricEmitter.cs b/src/Sentry/SentryMetricEmitter.cs index 69bc521469..d3f8aa194c 100644 --- a/src/Sentry/SentryMetricEmitter.cs +++ b/src/Sentry/SentryMetricEmitter.cs @@ -13,7 +13,7 @@ internal static SentryMetricEmitter Create(IHub hub, SentryOptions options, ISys internal static SentryMetricEmitter Create(IHub hub, SentryOptions options, ISystemClock clock, int batchCount, TimeSpan batchInterval) { - return options.Experimental.EnableMetrics + return options.EnableMetrics ? new DefaultSentryMetricEmitter(hub, options, clock, batchCount, batchInterval) : DisabledSentryMetricEmitter.Instance; } diff --git a/src/Sentry/SentryOptions.cs b/src/Sentry/SentryOptions.cs index 0a5ef9f47a..e8bd13d457 100644 --- a/src/Sentry/SentryOptions.cs +++ b/src/Sentry/SentryOptions.cs @@ -569,6 +569,32 @@ public void SetBeforeSendLog(Func beforeSendLog) _beforeSendLog = beforeSendLog; } + /// + /// When set to , the SDK does not generate and send metrics to Sentry via . + /// Defaults to . + /// + /// + public bool EnableMetrics { get; set; } = true; + + private Func? _beforeSendMetric; + + internal Func? BeforeSendMetricInternal => _beforeSendMetric; + + /// + /// Sets a callback function to be invoked before sending the metric to Sentry. + /// When the delegate throws an during invocation, the metric will not be captured. + /// + /// + /// It can be used to modify the metric object before being sent to Sentry. + /// To prevent the metric from being sent to Sentry, return . + /// Supported numeric value types are , , , , , and . + /// + /// + public void SetBeforeSendMetric(Func beforeSendMetric) + { + _beforeSendMetric = beforeSendMetric; + } + private int _maxQueueItems = 30; /// @@ -1907,51 +1933,4 @@ internal static List GetDefaultInAppExclude() => InAppExcludeRegexes.LibMonoSgen, InAppExcludeRegexes.LibXamarin ]; - - /// - /// Sentry features that are currently in an experimental state. - /// - /// - /// Experimental features are subject to binary, source and behavioral breaking changes in future updates. - /// - public ExperimentalSentryOptions Experimental { get; } = new ExperimentalSentryOptions(); - - /// - /// Sentry features that are currently in an experimental state. - /// - /// - /// Experimental features are subject to binary, source and behavioral breaking changes in future updates. - /// - public class ExperimentalSentryOptions - { - private Func? _beforeSendMetric; - - internal ExperimentalSentryOptions() - { - } - - internal Func? BeforeSendMetricInternal => _beforeSendMetric; - - /// - /// When set to , the SDK does not generate and send metrics to Sentry via . - /// Defaults to . - /// - /// - public bool EnableMetrics { get; set; } = true; - - /// - /// Sets a callback function to be invoked before sending the metric to Sentry. - /// When the delegate throws an during invocation, the metric will not be captured. - /// - /// - /// It can be used to modify the metric object before being sent to Sentry. - /// To prevent the metric from being sent to Sentry, return . - /// Supported numeric value types are , , , , , and . - /// - /// - public void SetBeforeSendMetric(Func beforeSendMetric) - { - _beforeSendMetric = beforeSendMetric; - } - } } diff --git a/src/Sentry/SentrySdk.cs b/src/Sentry/SentrySdk.cs index a7a5f7b096..fd7a6bd90f 100644 --- a/src/Sentry/SentrySdk.cs +++ b/src/Sentry/SentrySdk.cs @@ -288,6 +288,9 @@ public void Dispose() /// public static SentryStructuredLogger Logger { [DebuggerStepThrough] get => CurrentHub.Logger; } + /// + public static SentryMetricEmitter Metrics { [DebuggerStepThrough] get => CurrentHub.Metrics; } + /// /// Creates a new scope that will terminate when disposed. /// @@ -857,30 +860,4 @@ public static void CauseCrash(CrashType crashType) [DllImport("libc", EntryPoint = "strlen")] private static extern IntPtr NativeStrlenLibC(IntPtr strt); #endif - - /// - /// Sentry features that are currently in an experimental state. - /// - /// - /// Experimental features are subject to binary, source and behavioral breaking changes in future updates. - /// - public static ExperimentalSentrySdk Experimental { get; } = new(); - - /// - /// Sentry features that are currently in an experimental state. - /// - /// - /// Experimental features are subject to binary, source and behavioral breaking changes in future updates. - /// - public sealed class ExperimentalSentrySdk - { - internal ExperimentalSentrySdk() - { - } - -#pragma warning disable SENTRYTRACECONNECTEDMETRICS - /// - public SentryMetricEmitter Metrics { [DebuggerStepThrough] get => CurrentHub.Metrics; } -#pragma warning restore SENTRYTRACECONNECTEDMETRICS - } } diff --git a/test/Sentry.Testing/BindableTests.cs b/test/Sentry.Testing/BindableTests.cs index 69968238c8..68dd553a36 100644 --- a/test/Sentry.Testing/BindableTests.cs +++ b/test/Sentry.Testing/BindableTests.cs @@ -32,7 +32,6 @@ private static IEnumerable GetBindableProperties(IEnumerable configureScope); @@ -806,10 +805,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -894,14 +893,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -931,11 +926,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -995,10 +990,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { @@ -1490,7 +1481,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1539,7 +1529,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 64869d4587..d614075852 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -197,7 +197,6 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -806,10 +805,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -894,14 +893,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -931,11 +926,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -995,10 +990,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { @@ -1490,7 +1481,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1539,7 +1529,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 64869d4587..d614075852 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -197,7 +197,6 @@ namespace Sentry bool IsSessionActive { get; } Sentry.SentryId LastEventId { get; } Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] Sentry.SentryMetricEmitter Metrics { get; } void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); @@ -806,10 +805,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -894,14 +893,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -931,11 +926,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -995,10 +990,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { @@ -1490,7 +1481,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void BindClient(Sentry.ISentryClient client) { } public void BindException(System.Exception exception, Sentry.ISpan span) { } @@ -1539,7 +1529,6 @@ namespace Sentry.Extensibility public bool IsSessionActive { get; } public Sentry.SentryId LastEventId { get; } public Sentry.SentryStructuredLogger Logger { get; } - [System.Diagnostics.CodeAnalysis.Experimental("SENTRYTRACECONNECTEDMETRICS", UrlFormat="https://github.com/getsentry/sentry-dotnet/discussions/4838")] public Sentry.SentryMetricEmitter Metrics { get; } public void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public void AddBreadcrumb(Sentry.Infrastructure.ISystemClock clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index fbf517dd1e..8d15f59117 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -792,10 +792,10 @@ namespace Sentry public string? Dsn { get; set; } public bool EnableBackpressureHandling { get; set; } public bool EnableLogs { get; set; } + public bool EnableMetrics { get; set; } public bool EnableScopeSync { get; set; } public bool EnableSpotlight { get; set; } public string? Environment { get; set; } - public Sentry.SentryOptions.ExperimentalSentryOptions Experimental { get; } public System.Collections.Generic.IList FailedRequestStatusCodes { get; set; } public System.Collections.Generic.IList FailedRequestTargets { get; set; } public System.TimeSpan FlushTimeout { get; set; } @@ -874,14 +874,10 @@ namespace Sentry public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSend(System.Func beforeSend) { } public void SetBeforeSendLog(System.Func beforeSendLog) { } + public void SetBeforeSendMetric(System.Func beforeSendMetric) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public void SetBeforeSendTransaction(System.Func beforeSendTransaction) { } public Sentry.SentryOptions UseStackTraceFactory(Sentry.Extensibility.ISentryStackTraceFactory sentryStackTraceFactory) { } - public class ExperimentalSentryOptions - { - public bool EnableMetrics { get; set; } - public void SetBeforeSendMetric(System.Func beforeSendMetric) { } - } } public sealed class SentryPackage : Sentry.ISentryJsonSerializable { @@ -911,11 +907,11 @@ namespace Sentry } public static class SentrySdk { - public static Sentry.SentrySdk.ExperimentalSentrySdk Experimental { get; } public static bool IsEnabled { get; } public static bool IsSessionActive { get; } public static Sentry.SentryId LastEventId { get; } public static Sentry.SentryStructuredLogger Logger { get; } + public static Sentry.SentryMetricEmitter Metrics { get; } public static void AddBreadcrumb(Sentry.Breadcrumb breadcrumb, Sentry.SentryHint? hint = null) { } public static void AddBreadcrumb(string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } public static void AddBreadcrumb(Sentry.Infrastructure.ISystemClock? clock, string message, string? category = null, string? type = null, System.Collections.Generic.IDictionary? data = null, Sentry.BreadcrumbLevel level = 0) { } @@ -975,10 +971,6 @@ namespace Sentry public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { } public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { } public static void UnsetTag(string key) { } - public sealed class ExperimentalSentrySdk - { - public Sentry.SentryMetricEmitter Metrics { get; } - } } public class SentrySession : Sentry.ISentrySession { diff --git a/test/Sentry.Tests/HubTests.cs b/test/Sentry.Tests/HubTests.cs index c8bb6ea702..7f549aea4e 100644 --- a/test/Sentry.Tests/HubTests.cs +++ b/test/Sentry.Tests/HubTests.cs @@ -1883,7 +1883,7 @@ public void Logger_Dispose_DoesCaptureLog() public void Metrics_IsDisabled_DoesNotCaptureMetric() { // Arrange - _fixture.Options.Experimental.EnableMetrics = false; + _fixture.Options.EnableMetrics = false; var hub = _fixture.GetSut(); // Act @@ -1903,7 +1903,7 @@ public void Metrics_IsDisabled_DoesNotCaptureMetric() public void Metrics_IsEnabled_DoesCaptureMetric() { // Arrange - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var hub = _fixture.GetSut(); // Act @@ -1923,11 +1923,11 @@ public void Metrics_IsEnabled_DoesCaptureMetric() public void Metrics_EnableAfterCreate_HasNoEffect() { // Arrange - _fixture.Options.Experimental.EnableMetrics = false; + _fixture.Options.EnableMetrics = false; var hub = _fixture.GetSut(); // Act - _fixture.Options.Experimental.EnableMetrics = true; + _fixture.Options.EnableMetrics = true; // Assert hub.Metrics.Should().BeOfType(); @@ -1937,11 +1937,11 @@ public void Metrics_EnableAfterCreate_HasNoEffect() public void Metrics_DisableAfterCreate_HasNoEffect() { // Arrange - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var hub = _fixture.GetSut(); // Act - _fixture.Options.Experimental.EnableMetrics = false; + _fixture.Options.EnableMetrics = false; // Assert hub.Metrics.Should().BeOfType(); @@ -1951,7 +1951,7 @@ public void Metrics_DisableAfterCreate_HasNoEffect() public async Task Metrics_FlushAsync_DoesCaptureMetric() { // Arrange - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var hub = _fixture.GetSut(); // Act @@ -1976,7 +1976,7 @@ await _fixture.Client.Received(1).FlushAsync( public void Metrics_Dispose_DoesCaptureMetric() { // Arrange - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var hub = _fixture.GetSut(); // Act diff --git a/test/Sentry.Tests/SentryMetricEmitterTests.Options.cs b/test/Sentry.Tests/SentryMetricEmitterTests.Options.cs index e6c5d10132..10bc6db12d 100644 --- a/test/Sentry.Tests/SentryMetricEmitterTests.Options.cs +++ b/test/Sentry.Tests/SentryMetricEmitterTests.Options.cs @@ -9,7 +9,7 @@ public void EnableMetrics_Default_True() { var options = new SentryOptions(); - options.Experimental.EnableMetrics.Should().BeTrue(); + options.EnableMetrics.Should().BeTrue(); } [Fact] @@ -17,22 +17,22 @@ public void BeforeSendMetric_Default_Null() { var options = new SentryOptions(); - options.Experimental.BeforeSendMetricInternal.Should().BeNull(); + options.BeforeSendMetricInternal.Should().BeNull(); } [Fact] public void BeforeSendMetric_Set_NotNull() { - _fixture.Options.Experimental.SetBeforeSendMetric(static (SentryMetric metric) => metric); + _fixture.Options.SetBeforeSendMetric(static (SentryMetric metric) => metric); - _fixture.Options.Experimental.BeforeSendMetricInternal.Should().NotBeNull(); + _fixture.Options.BeforeSendMetricInternal.Should().NotBeNull(); } [Fact] public void BeforeSendMetric_SetNull_Null() { - _fixture.Options.Experimental.SetBeforeSendMetric(null!); + _fixture.Options.SetBeforeSendMetric(null!); - _fixture.Options.Experimental.BeforeSendMetricInternal.Should().BeNull(); + _fixture.Options.BeforeSendMetricInternal.Should().BeNull(); } } diff --git a/test/Sentry.Tests/SentryMetricEmitterTests.Types.cs b/test/Sentry.Tests/SentryMetricEmitterTests.Types.cs index 38b2d40ff0..cb6a959a1b 100644 --- a/test/Sentry.Tests/SentryMetricEmitterTests.Types.cs +++ b/test/Sentry.Tests/SentryMetricEmitterTests.Types.cs @@ -10,7 +10,7 @@ public partial class SentryMetricEmitterTests [InlineData(SentryMetricType.Distribution)] public void Emit_Enabled_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -29,7 +29,7 @@ public void Emit_Enabled_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Disabled_DoesNotCaptureEnvelope(SentryMetricType type) { - _fixture.Options.Experimental.EnableMetrics = false; + _fixture.Options.EnableMetrics = false; var metrics = _fixture.GetSut(); metrics.Emit(type, 1, []); @@ -44,7 +44,7 @@ public void Emit_Disabled_DoesNotCaptureEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Attributes_Enabled_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -63,7 +63,7 @@ public void Emit_Attributes_Enabled_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Attributes_Disabled_DoesNotCaptureEnvelope(SentryMetricType type) { - _fixture.Options.Experimental.EnableMetrics = false; + _fixture.Options.EnableMetrics = false; var metrics = _fixture.GetSut(); metrics.Emit(type, 1, [new KeyValuePair("attribute-key", "attribute-value")]); @@ -78,7 +78,7 @@ public void Emit_Attributes_Disabled_DoesNotCaptureEnvelope(SentryMetricType typ [InlineData(SentryMetricType.Distribution)] public void Emit_Byte_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -97,7 +97,7 @@ public void Emit_Byte_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Int16_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -116,7 +116,7 @@ public void Emit_Int16_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Int32_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -135,7 +135,7 @@ public void Emit_Int32_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Int64_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -154,7 +154,7 @@ public void Emit_Int64_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Single_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -173,7 +173,7 @@ public void Emit_Single_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Double_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -192,7 +192,7 @@ public void Emit_Double_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Decimal_DoesNotCaptureEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); metrics.Emit(type, 1m, []); @@ -213,7 +213,7 @@ public void Emit_Decimal_DoesNotCaptureEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Half_DoesNotCaptureEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); metrics.Emit(type, Half.One, []); @@ -234,7 +234,7 @@ public void Emit_Half_DoesNotCaptureEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Enum_DoesNotCaptureEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); metrics.Emit(type, (StringComparison)1, []); @@ -254,7 +254,7 @@ public void Emit_Enum_DoesNotCaptureEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution, nameof(SentryMetricType.Distribution), typeof(int))] public void Emit_Name_Null_DoesNotCaptureEnvelope(SentryMetricType type, string arg0, Type arg1) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); metrics.Emit(type, null!, 1); @@ -274,7 +274,7 @@ public void Emit_Name_Null_DoesNotCaptureEnvelope(SentryMetricType type, string [InlineData(SentryMetricType.Distribution, nameof(SentryMetricType.Distribution), typeof(int))] public void Emit_Name_Empty_DoesNotCaptureEnvelope(SentryMetricType type, string arg0, Type arg1) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); metrics.Emit(type, "", 1); @@ -320,7 +320,7 @@ public void Type_EmitMethods_StringUnitParameterOverloadsAreObsoleteForForwardCo [InlineData(SentryMetricType.Distribution)] public void Emit_Unit_String_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -338,7 +338,7 @@ public void Emit_Unit_String_CapturesEnvelope(SentryMetricType type) [InlineData(SentryMetricType.Distribution)] public void Emit_Unit_MeasurementUnit_CapturesEnvelope(SentryMetricType type) { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; diff --git a/test/Sentry.Tests/SentryMetricEmitterTests.Values.cs b/test/Sentry.Tests/SentryMetricEmitterTests.Values.cs index d8a3d251b3..497fbffa4f 100644 --- a/test/Sentry.Tests/SentryMetricEmitterTests.Values.cs +++ b/test/Sentry.Tests/SentryMetricEmitterTests.Values.cs @@ -107,7 +107,7 @@ public void TryGetValue_FromDecimal_UnsupportedType() public void Emit_Unit_MeasurementUnit_Predefined(MeasurementUnit unit, string expected) { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -124,7 +124,7 @@ public void Emit_Unit_MeasurementUnit_Predefined(MeasurementUnit unit, string ex public void Emit_Unit_MeasurementUnit_None() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -141,7 +141,7 @@ public void Emit_Unit_MeasurementUnit_None() public void Emit_Unit_MeasurementUnit_Custom() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -158,7 +158,7 @@ public void Emit_Unit_MeasurementUnit_Custom() public void Emit_Unit_MeasurementUnit_Empty() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -175,7 +175,7 @@ public void Emit_Unit_MeasurementUnit_Empty() public void Emit_Unit_MeasurementUnit_Null() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -192,7 +192,7 @@ public void Emit_Unit_MeasurementUnit_Null() public void Emit_Unit_MeasurementUnit_Default() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -210,7 +210,7 @@ public void Emit_Unit_MeasurementUnit_Default() public void Emit_Unit_String_Custom() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -228,7 +228,7 @@ public void Emit_Unit_String_Custom() public void Emit_Unit_String_Empty() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -246,7 +246,7 @@ public void Emit_Unit_String_Empty() public void Emit_Unit_String_Null() { SentryMetric? captured = null; - _fixture.Options.Experimental.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => + _fixture.Options.SetBeforeSendMetric(SentryMetric? (SentryMetric metric) => { captured = metric; return null; @@ -259,6 +259,7 @@ public void Emit_Unit_String_Null() captured.Unit.Should().BeNull(); } + [SuppressMessage("Performance", "CA1859:Use concrete types when possible for improved performance", Justification = "The generic SentryMetric type is internal. Testing via the public abstract base type.")] private static SentryMetric CreateCounter(T value) where T : struct { return new SentryMetric(DateTimeOffset.MinValue, SentryId.Empty, SentryMetricType.Counter, "sentry_tests.sentry_trace_metrics_tests.counter", value); diff --git a/test/Sentry.Tests/SentryMetricEmitterTests.cs b/test/Sentry.Tests/SentryMetricEmitterTests.cs index c3a47eebda..84c850ed05 100644 --- a/test/Sentry.Tests/SentryMetricEmitterTests.cs +++ b/test/Sentry.Tests/SentryMetricEmitterTests.cs @@ -76,7 +76,7 @@ public void Dispose() [Fact] public void Create_Enabled_NewDefaultInstance() { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var instance = _fixture.GetSut(); var other = _fixture.GetSut(); @@ -88,7 +88,7 @@ public void Create_Enabled_NewDefaultInstance() [Fact] public void Create_Disabled_CachedDisabledInstance() { - _fixture.Options.Experimental.EnableMetrics = false; + _fixture.Options.EnableMetrics = false; var instance = _fixture.GetSut(); var other = _fixture.GetSut(); @@ -101,7 +101,7 @@ public void Create_Disabled_CachedDisabledInstance() public void Emit_WithoutActiveSpan_CapturesEnvelope() { _fixture.WithoutActiveSpan(); - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -120,8 +120,8 @@ public void Emit_WithBeforeSendMetric_InvokesCallback() var invocations = 0; SentryMetric configuredMetric = null!; - Assert.True(_fixture.Options.Experimental.EnableMetrics); - _fixture.Options.Experimental.SetBeforeSendMetric((SentryMetric metric) => + Assert.True(_fixture.Options.EnableMetrics); + _fixture.Options.SetBeforeSendMetric((SentryMetric metric) => { invocations++; configuredMetric = metric; @@ -142,8 +142,8 @@ public void Emit_WhenBeforeSendMetricReturnsNull_DoesNotCaptureEnvelope() { var invocations = 0; - Assert.True(_fixture.Options.Experimental.EnableMetrics); - _fixture.Options.Experimental.SetBeforeSendMetric((SentryMetric metric) => + Assert.True(_fixture.Options.EnableMetrics); + _fixture.Options.SetBeforeSendMetric((SentryMetric metric) => { invocations++; return null; @@ -159,8 +159,8 @@ public void Emit_WhenBeforeSendMetricReturnsNull_DoesNotCaptureEnvelope() [Fact] public void Emit_InvalidBeforeSendMetric_DoesNotCaptureEnvelope() { - Assert.True(_fixture.Options.Experimental.EnableMetrics); - _fixture.Options.Experimental.SetBeforeSendMetric(static (SentryMetric metric) => throw new InvalidOperationException()); + Assert.True(_fixture.Options.EnableMetrics); + _fixture.Options.SetBeforeSendMetric(static (SentryMetric metric) => throw new InvalidOperationException()); var metrics = _fixture.GetSut(); metrics.EmitCounter("sentry_tests.sentry_trace_metrics_tests.counter", 1); @@ -176,7 +176,7 @@ public void Emit_InvalidBeforeSendMetric_DoesNotCaptureEnvelope() [Fact] public void Flush_AfterEmit_CapturesEnvelope() { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); Envelope envelope = null!; @@ -198,7 +198,7 @@ public void Flush_AfterEmit_CapturesEnvelope() [Fact] public void Dispose_BeforeEmit_DoesNotCaptureEnvelope() { - Assert.True(_fixture.Options.Experimental.EnableMetrics); + Assert.True(_fixture.Options.EnableMetrics); var metrics = _fixture.GetSut(); var defaultMetrics = metrics.Should().BeOfType().Which;