From c153f8d4305460aaab667f959c389a5b30e15f87 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 5 Aug 2025 21:18:45 +1200 Subject: [PATCH] chore: Remove dangling experimental metrics classes Resolves #4404 - https://github.com/getsentry/sentry-dotnet/issues/4404 #skip-changelog --- src/Sentry/BuiltInSystemDiagnosticsMeters.cs | 249 ------------------ src/Sentry/ExperimentalMetricsOptions.cs | 61 ----- ...piApprovalTests.Run.DotNet8_0.verified.txt | 23 -- ...piApprovalTests.Run.DotNet9_0.verified.txt | 23 -- .../ApiApprovalTests.Run.Net4_8.verified.txt | 23 -- .../BuiltInSystemDiagnosticsMetersTests.cs | 104 -------- 6 files changed, 483 deletions(-) delete mode 100644 src/Sentry/BuiltInSystemDiagnosticsMeters.cs delete mode 100644 src/Sentry/ExperimentalMetricsOptions.cs delete mode 100644 test/Sentry.Tests/BuiltInSystemDiagnosticsMetersTests.cs diff --git a/src/Sentry/BuiltInSystemDiagnosticsMeters.cs b/src/Sentry/BuiltInSystemDiagnosticsMeters.cs deleted file mode 100644 index 145546897f..0000000000 --- a/src/Sentry/BuiltInSystemDiagnosticsMeters.cs +++ /dev/null @@ -1,249 +0,0 @@ -using Sentry.Internal; - -namespace Sentry; - -/// -/// Well known values for built-in metrics that can be configured for -/// -/// -public static partial class BuiltInSystemDiagnosticsMeters -{ - private const string MicrosoftAspNetCoreHostingPattern = @"^Microsoft\.AspNetCore\.Hosting$"; - private const string MicrosoftAspNetCoreRoutingPattern = @"^Microsoft\.AspNetCore\.Routing$"; - private const string MicrosoftAspNetCoreDiagnosticsPattern = @"^Microsoft\.AspNetCore\.Diagnostics$"; - private const string MicrosoftAspNetCoreRateLimitingPattern = @"^Microsoft\.AspNetCore\.RateLimiting$"; - private const string MicrosoftAspNetCoreHeaderParsingPattern = @"^Microsoft\.AspNetCore\.HeaderParsing$"; - private const string MicrosoftAspNetCoreServerKestrelPattern = @"^Microsoft\.AspNetCore\.Server\.Kestrel$"; - private const string MicrosoftAspNetCoreHttpConnectionsPattern = @"^Microsoft\.AspNetCore\.Http\.Connections$"; - private const string MicrosoftExtensionsDiagnosticsHealthChecksPattern = @"^Microsoft\.Extensions\.Diagnostics\.HealthChecks$"; - private const string MicrosoftExtensionsDiagnosticsResourceMonitoringPattern = @"^Microsoft\.Extensions\.Diagnostics\.ResourceMonitoring$"; - private const string OpenTelemetryInstrumentationRuntimePattern = @"^OpenTelemetry\.Instrumentation\.Runtime$"; - private const string SystemNetNameResolutionPattern = @"^System\.Net\.NameResolution$"; - private const string SystemNetHttpPattern = @"^System\.Net\.Http$"; - - /// - /// Matches the built-in Microsoft.AspNetCore.Hosting metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreHosting = MicrosoftAspNetCoreHostingRegex; - - [GeneratedRegex(MicrosoftAspNetCoreHostingPattern)] - private static partial Regex MicrosoftAspNetCoreHostingRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreHosting = MicrosoftAspNetCoreHostingRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreHostingPattern)] - private static partial Regex MicrosoftAspNetCoreHostingRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreHosting = new Regex(MicrosoftAspNetCoreHostingPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.AspNetCore.Routing metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreRouting = MicrosoftAspNetCoreRoutingRegex; - - [GeneratedRegex(MicrosoftAspNetCoreRoutingPattern)] - private static partial Regex MicrosoftAspNetCoreRoutingRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreRouting = MicrosoftAspNetCoreRoutingRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreRoutingPattern)] - private static partial Regex MicrosoftAspNetCoreRoutingRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreRouting = new Regex(MicrosoftAspNetCoreRoutingPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.AspNetCore.Diagnostics metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreDiagnostics = MicrosoftAspNetCoreDiagnosticsRegex; - - [GeneratedRegex(MicrosoftAspNetCoreDiagnosticsPattern)] - private static partial Regex MicrosoftAspNetCoreDiagnosticsRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreDiagnostics = MicrosoftAspNetCoreDiagnosticsRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreDiagnosticsPattern)] - private static partial Regex MicrosoftAspNetCoreDiagnosticsRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreDiagnostics = new Regex(MicrosoftAspNetCoreDiagnosticsPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.AspNetCore.RateLimiting metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreRateLimiting = MicrosoftAspNetCoreRateLimitingRegex; - - [GeneratedRegex(MicrosoftAspNetCoreRateLimitingPattern)] - private static partial Regex MicrosoftAspNetCoreRateLimitingRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreRateLimiting = MicrosoftAspNetCoreRateLimitingRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreRateLimitingPattern)] - private static partial Regex MicrosoftAspNetCoreRateLimitingRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreRateLimiting = new Regex(MicrosoftAspNetCoreRateLimitingPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.AspNetCore.HeaderParsing metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreHeaderParsing = MicrosoftAspNetCoreHeaderParsingRegex; - - [GeneratedRegex(MicrosoftAspNetCoreHeaderParsingPattern)] - private static partial Regex MicrosoftAspNetCoreHeaderParsingRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreHeaderParsing = MicrosoftAspNetCoreHeaderParsingRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreHeaderParsingPattern)] - private static partial Regex MicrosoftAspNetCoreHeaderParsingRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreHeaderParsing = new Regex(MicrosoftAspNetCoreHeaderParsingPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.AspNetCore.Server.Kestrel metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreServerKestrel = MicrosoftAspNetCoreServerKestrelRegex; - - [GeneratedRegex(MicrosoftAspNetCoreServerKestrelPattern)] - private static partial Regex MicrosoftAspNetCoreServerKestrelRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreServerKestrel = MicrosoftAspNetCoreServerKestrelRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreServerKestrelPattern)] - private static partial Regex MicrosoftAspNetCoreServerKestrelRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreServerKestrel = new Regex(MicrosoftAspNetCoreServerKestrelPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.AspNetCore.Http.Connections metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftAspNetCoreHttpConnections = MicrosoftAspNetCoreHttpConnectionsRegex; - - [GeneratedRegex(MicrosoftAspNetCoreHttpConnectionsPattern)] - private static partial Regex MicrosoftAspNetCoreHttpConnectionsRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftAspNetCoreHttpConnections = MicrosoftAspNetCoreHttpConnectionsRegex(); - - [GeneratedRegex(MicrosoftAspNetCoreHttpConnectionsPattern)] - private static partial Regex MicrosoftAspNetCoreHttpConnectionsRegex(); -#else - public static readonly StringOrRegex MicrosoftAspNetCoreHttpConnections = new Regex(MicrosoftAspNetCoreHttpConnectionsPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.Extensions.Diagnostics.HealthChecks metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftExtensionsDiagnosticsHealthChecks = MicrosoftExtensionsDiagnosticsHealthChecksRegex; - - [GeneratedRegex(MicrosoftExtensionsDiagnosticsHealthChecksPattern)] - private static partial Regex MicrosoftExtensionsDiagnosticsHealthChecksRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftExtensionsDiagnosticsHealthChecks = MicrosoftExtensionsDiagnosticsHealthChecksRegex(); - - [GeneratedRegex(MicrosoftExtensionsDiagnosticsHealthChecksPattern)] - private static partial Regex MicrosoftExtensionsDiagnosticsHealthChecksRegex(); -#else - public static readonly StringOrRegex MicrosoftExtensionsDiagnosticsHealthChecks = new Regex(MicrosoftExtensionsDiagnosticsHealthChecksPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in Microsoft.Extensions.Diagnostics.ResourceMonitoring metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex MicrosoftExtensionsDiagnosticsResourceMonitoring = MicrosoftExtensionsDiagnosticsResourceMonitoringRegex; - - [GeneratedRegex(MicrosoftExtensionsDiagnosticsResourceMonitoringPattern)] - private static partial Regex MicrosoftExtensionsDiagnosticsResourceMonitoringRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex MicrosoftExtensionsDiagnosticsResourceMonitoring = MicrosoftExtensionsDiagnosticsResourceMonitoringRegex(); - - [GeneratedRegex(MicrosoftExtensionsDiagnosticsResourceMonitoringPattern)] - private static partial Regex MicrosoftExtensionsDiagnosticsResourceMonitoringRegex(); -#else - public static readonly StringOrRegex MicrosoftExtensionsDiagnosticsResourceMonitoring = new Regex(MicrosoftExtensionsDiagnosticsResourceMonitoringPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in System.Net.NameResolution metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex OpenTelemetryInstrumentationRuntime = OpenTelemetryInstrumentationRuntimeRegex; - - [GeneratedRegex(OpenTelemetryInstrumentationRuntimePattern)] - private static partial Regex OpenTelemetryInstrumentationRuntimeRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex OpenTelemetryInstrumentationRuntime = OpenTelemetryInstrumentationRuntimeRegex(); - - [GeneratedRegex(OpenTelemetryInstrumentationRuntimePattern)] - private static partial Regex OpenTelemetryInstrumentationRuntimeRegex(); -#else - public static readonly StringOrRegex OpenTelemetryInstrumentationRuntime = new Regex(OpenTelemetryInstrumentationRuntimePattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in System.Net.NameResolution metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex SystemNetNameResolution = SystemNetNameResolutionRegex; - - [GeneratedRegex(SystemNetNameResolutionPattern)] - private static partial Regex SystemNetNameResolutionRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex SystemNetNameResolution = SystemNetNameResolutionRegex(); - - [GeneratedRegex(SystemNetNameResolutionPattern)] - private static partial Regex SystemNetNameResolutionRegex(); -#else - public static readonly StringOrRegex SystemNetNameResolution = new Regex(SystemNetNameResolutionPattern, RegexOptions.Compiled); -#endif - - /// - /// Matches the built-in metrics - /// -#if NET9_0_OR_GREATER - public static readonly StringOrRegex SystemNetHttp = SystemNetHttpRegex; - - [GeneratedRegex(SystemNetHttpPattern)] - private static partial Regex SystemNetHttpRegex { get; } -#elif NET8_0 - public static readonly StringOrRegex SystemNetHttp = SystemNetHttpRegex(); - - [GeneratedRegex(SystemNetHttpPattern)] - private static partial Regex SystemNetHttpRegex(); -#else - public static readonly StringOrRegex SystemNetHttp = new Regex(SystemNetHttpPattern, RegexOptions.Compiled); -#endif - - private static readonly Lazy> LazyAll = new(() => new List - { - MicrosoftAspNetCoreHosting, - MicrosoftAspNetCoreRouting, - MicrosoftAspNetCoreDiagnostics, - MicrosoftAspNetCoreRateLimiting, - MicrosoftAspNetCoreHeaderParsing, - MicrosoftAspNetCoreServerKestrel, - MicrosoftAspNetCoreHttpConnections, - MicrosoftExtensionsDiagnosticsHealthChecks, - MicrosoftExtensionsDiagnosticsResourceMonitoring, - OpenTelemetryInstrumentationRuntime, - SystemNetNameResolution, - SystemNetHttp, - }); - - /// - /// Matches all built-in metrics - /// - /// - public static IList All => LazyAll.Value; -} diff --git a/src/Sentry/ExperimentalMetricsOptions.cs b/src/Sentry/ExperimentalMetricsOptions.cs deleted file mode 100644 index 0b07ad0e0b..0000000000 --- a/src/Sentry/ExperimentalMetricsOptions.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Sentry.Internal; - -namespace Sentry; - -/// -/// Settings for the experimental Metrics feature. This feature is preview only and will very likely change in the future -/// without a major version bump... so use at your own risk. -/// -public class ExperimentalMetricsOptions -{ - /// - /// Determines whether code locations should be recorded for Metrics - /// - public bool EnableCodeLocations { get; set; } = true; - - private IList _captureSystemDiagnosticsInstruments = new List(); - - /// - /// - /// A list of Substrings or Regular Expressions. Any `System.Diagnostics.Metrics.Instrument` whose name - /// matches one of the items in this list will be collected and reported to Sentry. - /// - /// - /// These can be either custom Instruments that you have created or any of the built-in metrics that are available. - /// - /// - /// See https://learn.microsoft.com/en-us/dotnet/core/diagnostics/built-in-metrics for more information. - /// - /// - public IList CaptureSystemDiagnosticsInstruments - { - // NOTE: During configuration binding, .NET 6 and lower used to just call Add on the existing item. - // .NET 7 changed this to call the setter with an array that already starts with the old value. - // We have to handle both cases. - get => _captureSystemDiagnosticsInstruments; - set => _captureSystemDiagnosticsInstruments = value.WithConfigBinding(); - } - - private IList _captureSystemDiagnosticsMeters = BuiltInSystemDiagnosticsMeters.All; - - /// - /// - /// A list of Substrings or Regular Expressions. Instruments for any `System.Diagnostics.Metrics.Meter` - /// whose name matches one of the items in this list will be collected and reported to Sentry. - /// - /// - /// These can be either custom Instruments that you have created or any of the built-in metrics that are available. - /// - /// - /// See https://learn.microsoft.com/en-us/dotnet/core/diagnostics/built-in-metrics for more information. - /// - /// - public IList CaptureSystemDiagnosticsMeters - { - // NOTE: During configuration binding, .NET 6 and lower used to just call Add on the existing item. - // .NET 7 changed this to call the setter with an array that already starts with the old value. - // We have to handle both cases. - get => _captureSystemDiagnosticsMeters; - set => _captureSystemDiagnosticsMeters = value.WithConfigBinding(); - } -} diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 71d6bfb677..fee94cc19e 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -40,22 +40,6 @@ namespace Sentry [System.Runtime.Serialization.EnumMember(Value="critical")] Critical = 3, } - public static class BuiltInSystemDiagnosticsMeters - { - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreDiagnostics; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHeaderParsing; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHosting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHttpConnections; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreRateLimiting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreRouting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreServerKestrel; - public static readonly Sentry.StringOrRegex MicrosoftExtensionsDiagnosticsHealthChecks; - public static readonly Sentry.StringOrRegex MicrosoftExtensionsDiagnosticsResourceMonitoring; - public static readonly Sentry.StringOrRegex OpenTelemetryInstrumentationRuntime; - public static readonly Sentry.StringOrRegex SystemNetHttp; - public static readonly Sentry.StringOrRegex SystemNetNameResolution; - public static System.Collections.Generic.IList All { get; } - } public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } @@ -112,13 +96,6 @@ namespace Sentry public static void SetFingerprint(this Sentry.IEventLike eventLike, System.Collections.Generic.IEnumerable fingerprint) { } public static void SetFingerprint(this Sentry.IEventLike eventLike, params string[] fingerprint) { } } - public class ExperimentalMetricsOptions - { - public ExperimentalMetricsOptions() { } - public System.Collections.Generic.IList CaptureSystemDiagnosticsInstruments { get; set; } - public System.Collections.Generic.IList CaptureSystemDiagnosticsMeters { get; set; } - public bool EnableCodeLocations { get; set; } - } public class FileAttachmentContent : Sentry.IAttachmentContent { public FileAttachmentContent(string filePath) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 71d6bfb677..fee94cc19e 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -40,22 +40,6 @@ namespace Sentry [System.Runtime.Serialization.EnumMember(Value="critical")] Critical = 3, } - public static class BuiltInSystemDiagnosticsMeters - { - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreDiagnostics; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHeaderParsing; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHosting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHttpConnections; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreRateLimiting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreRouting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreServerKestrel; - public static readonly Sentry.StringOrRegex MicrosoftExtensionsDiagnosticsHealthChecks; - public static readonly Sentry.StringOrRegex MicrosoftExtensionsDiagnosticsResourceMonitoring; - public static readonly Sentry.StringOrRegex OpenTelemetryInstrumentationRuntime; - public static readonly Sentry.StringOrRegex SystemNetHttp; - public static readonly Sentry.StringOrRegex SystemNetNameResolution; - public static System.Collections.Generic.IList All { get; } - } public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } @@ -112,13 +96,6 @@ namespace Sentry public static void SetFingerprint(this Sentry.IEventLike eventLike, System.Collections.Generic.IEnumerable fingerprint) { } public static void SetFingerprint(this Sentry.IEventLike eventLike, params string[] fingerprint) { } } - public class ExperimentalMetricsOptions - { - public ExperimentalMetricsOptions() { } - public System.Collections.Generic.IList CaptureSystemDiagnosticsInstruments { get; set; } - public System.Collections.Generic.IList CaptureSystemDiagnosticsMeters { get; set; } - public bool EnableCodeLocations { get; set; } - } public class FileAttachmentContent : Sentry.IAttachmentContent { public FileAttachmentContent(string filePath) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 8b32fbc30f..121c59f5d4 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -40,22 +40,6 @@ namespace Sentry [System.Runtime.Serialization.EnumMember(Value="critical")] Critical = 3, } - public static class BuiltInSystemDiagnosticsMeters - { - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreDiagnostics; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHeaderParsing; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHosting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreHttpConnections; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreRateLimiting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreRouting; - public static readonly Sentry.StringOrRegex MicrosoftAspNetCoreServerKestrel; - public static readonly Sentry.StringOrRegex MicrosoftExtensionsDiagnosticsHealthChecks; - public static readonly Sentry.StringOrRegex MicrosoftExtensionsDiagnosticsResourceMonitoring; - public static readonly Sentry.StringOrRegex OpenTelemetryInstrumentationRuntime; - public static readonly Sentry.StringOrRegex SystemNetHttp; - public static readonly Sentry.StringOrRegex SystemNetNameResolution; - public static System.Collections.Generic.IList All { get; } - } public class ByteAttachmentContent : Sentry.IAttachmentContent { public ByteAttachmentContent(byte[] bytes) { } @@ -102,13 +86,6 @@ namespace Sentry public static void SetFingerprint(this Sentry.IEventLike eventLike, System.Collections.Generic.IEnumerable fingerprint) { } public static void SetFingerprint(this Sentry.IEventLike eventLike, params string[] fingerprint) { } } - public class ExperimentalMetricsOptions - { - public ExperimentalMetricsOptions() { } - public System.Collections.Generic.IList CaptureSystemDiagnosticsInstruments { get; set; } - public System.Collections.Generic.IList CaptureSystemDiagnosticsMeters { get; set; } - public bool EnableCodeLocations { get; set; } - } public class FileAttachmentContent : Sentry.IAttachmentContent { public FileAttachmentContent(string filePath) { } diff --git a/test/Sentry.Tests/BuiltInSystemDiagnosticsMetersTests.cs b/test/Sentry.Tests/BuiltInSystemDiagnosticsMetersTests.cs deleted file mode 100644 index c9b045f776..0000000000 --- a/test/Sentry.Tests/BuiltInSystemDiagnosticsMetersTests.cs +++ /dev/null @@ -1,104 +0,0 @@ -namespace Sentry.Tests; - -public class BuiltInSystemDiagnosticsMetersTests -{ - [Fact] - public void MicrosoftAspNetCoreHosting_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreHosting; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.Hosting"); - } - - [Fact] - public void MicrosoftAspNetCoreRouting_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreRouting; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.Routing"); - } - - [Fact] - public void MicrosoftAspNetCoreDiagnostics_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreDiagnostics; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.Diagnostics"); - } - - [Fact] - public void MicrosoftAspNetCoreRateLimiting_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreRateLimiting; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.RateLimiting"); - } - - [Fact] - public void MicrosoftAspNetCoreHeaderParsing_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreHeaderParsing; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.HeaderParsing"); - } - - [Fact] - public void MicrosoftAspNetCoreServerKestrel_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreServerKestrel; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.Server.Kestrel"); - } - - [Fact] - public void MicrosoftAspNetCoreHttpConnections_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftAspNetCoreHttpConnections; - - pattern.ShouldMatchOnlyExactText("Microsoft.AspNetCore.Http.Connections"); - } - - [Fact] - public void MicrosoftExtensionsDiagnosticsHealthChecks_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftExtensionsDiagnosticsHealthChecks; - - pattern.ShouldMatchOnlyExactText("Microsoft.Extensions.Diagnostics.HealthChecks"); - } - - [Fact] - public void MicrosoftExtensionsDiagnosticsResourceMonitoring_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.MicrosoftExtensionsDiagnosticsResourceMonitoring; - - pattern.ShouldMatchOnlyExactText("Microsoft.Extensions.Diagnostics.ResourceMonitoring"); - } - - [Fact] - public void SystemNetNameResolution_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.SystemNetNameResolution; - - pattern.ShouldMatchOnlyExactText("System.Net.NameResolution"); - } - - [Fact] - public void SystemNetHttp_ExactString_Matches() - { - var pattern = BuiltInSystemDiagnosticsMeters.SystemNetHttp; - - pattern.ShouldMatchOnlyExactText("System.Net.Http"); - } -} - -internal static class BuiltInSystemDiagnosticsMetersTestsExtensions -{ - internal static void ShouldMatchOnlyExactText(this StringOrRegex pattern, string actual) - { - var withPrefix = "prefix" + actual; - var withSuffix = actual + "suffix"; - SubstringOrPatternMatcher.Default.IsMatch(pattern, actual).Should().BeTrue(); - SubstringOrPatternMatcher.Default.IsMatch(pattern, withPrefix).Should().BeFalse(); - SubstringOrPatternMatcher.Default.IsMatch(pattern, withSuffix).Should().BeFalse(); - } -}