From e26175e9528724fffc64c0d4887970e3339e059a Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 30 Jan 2024 15:18:01 +1300 Subject: [PATCH] Integrating review feedback --- src/Sentry/BuiltInSystemDiagnosticsMeters.cs | 15 +++++++++------ .../Internal/SystemDiagnosticsMetricsListener.cs | 2 +- .../ApiApprovalTests.Run.DotNet6_0.verified.txt | 2 +- .../ApiApprovalTests.Run.DotNet7_0.verified.txt | 2 +- .../ApiApprovalTests.Run.DotNet8_0.verified.txt | 2 +- .../ApiApprovalTests.Run.Net4_8.verified.txt | 2 +- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Sentry/BuiltInSystemDiagnosticsMeters.cs b/src/Sentry/BuiltInSystemDiagnosticsMeters.cs index d79337dc78..be846b67d1 100644 --- a/src/Sentry/BuiltInSystemDiagnosticsMeters.cs +++ b/src/Sentry/BuiltInSystemDiagnosticsMeters.cs @@ -150,11 +150,8 @@ public static partial class BuiltInSystemDiagnosticsMeters public static readonly SubstringOrRegexPattern SystemNetHttp = new Regex(SystemNetHttpPattern, RegexOptions.Compiled); #endif - /// - /// Matches all built in metrics - /// - /// - public static IList All = [ + private static readonly Lazy> LazyAll = new(() => new List + { MicrosoftAspNetCoreHosting, MicrosoftAspNetCoreRouting, MicrosoftAspNetCoreDiagnostics, @@ -166,5 +163,11 @@ public static partial class BuiltInSystemDiagnosticsMeters SystemNetHttp, MicrosoftExtensionsDiagnosticsHealthChecks, MicrosoftExtensionsDiagnosticsResourceMonitoring - ]; + }); + + /// + /// Matches all built in metrics + /// + /// + public static IList All => LazyAll.Value; } diff --git a/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs b/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs index 7f6be88616..a18f618781 100644 --- a/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs +++ b/src/Sentry/Internal/SystemDiagnosticsMetricsListener.cs @@ -54,7 +54,7 @@ internal void RecordMeasurement( T measurement, ReadOnlySpan> tags, object? _) - where T: struct + where T: struct, IConvertible { var unit = MeasurementUnit.Parse(instrument.Unit); var tagDict = tags.ToImmutableArray().ToImmutableDictionary( diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt index ea49fd5aa7..6953004d5d 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt @@ -51,7 +51,6 @@ namespace Sentry } public static class BuiltInSystemDiagnosticsMeters { - public static System.Collections.Generic.IList All; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreDiagnostics; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHeaderParsing; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHosting; @@ -63,6 +62,7 @@ namespace Sentry public static readonly Sentry.SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsResourceMonitoring; public static readonly Sentry.SubstringOrRegexPattern SystemNetHttp; public static readonly Sentry.SubstringOrRegexPattern SystemNetNameResolution; + public static System.Collections.Generic.IList All { get; } } public class ByteAttachmentContent : Sentry.IAttachmentContent { diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt index ea49fd5aa7..6953004d5d 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt @@ -51,7 +51,6 @@ namespace Sentry } public static class BuiltInSystemDiagnosticsMeters { - public static System.Collections.Generic.IList All; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreDiagnostics; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHeaderParsing; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHosting; @@ -63,6 +62,7 @@ namespace Sentry public static readonly Sentry.SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsResourceMonitoring; public static readonly Sentry.SubstringOrRegexPattern SystemNetHttp; public static readonly Sentry.SubstringOrRegexPattern SystemNetNameResolution; + public static System.Collections.Generic.IList All { get; } } public class ByteAttachmentContent : Sentry.IAttachmentContent { diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index abd4650239..7c61203e2d 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -51,7 +51,6 @@ namespace Sentry } public static class BuiltInSystemDiagnosticsMeters { - public static System.Collections.Generic.IList All; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreDiagnostics; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHeaderParsing; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHosting; @@ -63,6 +62,7 @@ namespace Sentry public static readonly Sentry.SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsResourceMonitoring; public static readonly Sentry.SubstringOrRegexPattern SystemNetHttp; public static readonly Sentry.SubstringOrRegexPattern SystemNetNameResolution; + public static System.Collections.Generic.IList All { get; } } public class ByteAttachmentContent : Sentry.IAttachmentContent { diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index e64ee6f686..0dfecbc072 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -51,7 +51,6 @@ namespace Sentry } public static class BuiltInSystemDiagnosticsMeters { - public static System.Collections.Generic.IList All; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreDiagnostics; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHeaderParsing; public static readonly Sentry.SubstringOrRegexPattern MicrosoftAspNetCoreHosting; @@ -63,6 +62,7 @@ namespace Sentry public static readonly Sentry.SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsResourceMonitoring; public static readonly Sentry.SubstringOrRegexPattern SystemNetHttp; public static readonly Sentry.SubstringOrRegexPattern SystemNetNameResolution; + public static System.Collections.Generic.IList All { get; } } public class ByteAttachmentContent : Sentry.IAttachmentContent {