|
| 1 | +namespace Sentry; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Well known values for built in metrics that can be configured for |
| 5 | +/// <see cref="ExperimentalMetricsOptions.CaptureSystemDiagnosticsMeters"/> |
| 6 | +/// </summary> |
| 7 | +public static partial class BuiltInSystemDiagnosticsMeters |
| 8 | +{ |
| 9 | + private const string MicrosoftAspNetCoreHostingPattern = @"^Microsoft\.AspNetCore\.Hosting$"; |
| 10 | + private const string MicrosoftAspNetCoreRoutingPattern = @"^Microsoft\.AspNetCore\.Routing$"; |
| 11 | + private const string MicrosoftAspNetCoreDiagnosticsPattern = @"^Microsoft\.AspNetCore\.Diagnostics$"; |
| 12 | + private const string MicrosoftAspNetCoreRateLimitingPattern = @"^Microsoft\.AspNetCore\.RateLimiting$"; |
| 13 | + private const string MicrosoftAspNetCoreHeaderParsingPattern = @"^Microsoft\.AspNetCore\.HeaderParsing$"; |
| 14 | + private const string MicrosoftAspNetCoreServerKestrelPattern = @"^Microsoft\.AspNetCore\.Server\.Kestrel$"; |
| 15 | + private const string MicrosoftAspNetCoreHttpConnectionsPattern = @"^Microsoft\.AspNetCore\.Http\.Connections$"; |
| 16 | + private const string MicrosoftExtensionsDiagnosticsHealthChecksPattern = @"^Microsoft\.Extensions\.Diagnostics\.HealthChecks$"; |
| 17 | + private const string MicrosoftExtensionsDiagnosticsResourceMonitoringPattern = @"^Microsoft\.Extensions\.Diagnostics\.ResourceMonitoring$"; |
| 18 | + private const string SystemNetNameResolutionPattern = @"^System\.Net\.NameResolution$"; |
| 19 | + private const string SystemNetHttpPattern = @"^System\.Net\.Http$"; |
| 20 | + |
| 21 | + /// <summary> |
| 22 | + /// Matches the built in Microsoft.AspNetCore.Hosting metrics |
| 23 | + /// </summary> |
| 24 | +#if NET8_0_OR_GREATER |
| 25 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreHosting = MicrosoftAspNetCoreHostingRegex(); |
| 26 | + |
| 27 | + [GeneratedRegex(MicrosoftAspNetCoreHostingPattern, RegexOptions.Compiled)] |
| 28 | + private static partial Regex MicrosoftAspNetCoreHostingRegex(); |
| 29 | +#else |
| 30 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreHosting = new Regex(MicrosoftAspNetCoreHostingPattern, RegexOptions.Compiled); |
| 31 | +#endif |
| 32 | + |
| 33 | + /// <summary> |
| 34 | + /// Matches the built in Microsoft.AspNetCore.Routing metrics |
| 35 | + /// </summary> |
| 36 | +#if NET8_0_OR_GREATER |
| 37 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreRouting = MicrosoftAspNetCoreRoutingRegex(); |
| 38 | + |
| 39 | + [GeneratedRegex(MicrosoftAspNetCoreRoutingPattern, RegexOptions.Compiled)] |
| 40 | + private static partial Regex MicrosoftAspNetCoreRoutingRegex(); |
| 41 | +#else |
| 42 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreRouting = new Regex(MicrosoftAspNetCoreRoutingPattern, RegexOptions.Compiled); |
| 43 | +#endif |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// Matches the built in Microsoft.AspNetCore.Diagnostics metrics |
| 47 | + /// </summary> |
| 48 | +#if NET8_0_OR_GREATER |
| 49 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreDiagnostics = MicrosoftAspNetCoreDiagnosticsRegex(); |
| 50 | + |
| 51 | + [GeneratedRegex(MicrosoftAspNetCoreDiagnosticsPattern, RegexOptions.Compiled)] |
| 52 | + private static partial Regex MicrosoftAspNetCoreDiagnosticsRegex(); |
| 53 | +#else |
| 54 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreDiagnostics = new Regex(MicrosoftAspNetCoreDiagnosticsPattern, RegexOptions.Compiled); |
| 55 | +#endif |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Matches the built in Microsoft.AspNetCore.RateLimiting metrics |
| 59 | + /// </summary> |
| 60 | +#if NET8_0_OR_GREATER |
| 61 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreRateLimiting = MicrosoftAspNetCoreRateLimitingRegex(); |
| 62 | + |
| 63 | + [GeneratedRegex(MicrosoftAspNetCoreRateLimitingPattern, RegexOptions.Compiled)] |
| 64 | + private static partial Regex MicrosoftAspNetCoreRateLimitingRegex(); |
| 65 | +#else |
| 66 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreRateLimiting = new Regex(MicrosoftAspNetCoreRateLimitingPattern, RegexOptions.Compiled); |
| 67 | +#endif |
| 68 | + |
| 69 | + /// <summary> |
| 70 | + /// Matches the built in Microsoft.AspNetCore.HeaderParsing metrics |
| 71 | + /// </summary> |
| 72 | +#if NET8_0_OR_GREATER |
| 73 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreHeaderParsing = MicrosoftAspNetCoreHeaderParsingRegex(); |
| 74 | + |
| 75 | + [GeneratedRegex(MicrosoftAspNetCoreHeaderParsingPattern, RegexOptions.Compiled)] |
| 76 | + private static partial Regex MicrosoftAspNetCoreHeaderParsingRegex(); |
| 77 | +#else |
| 78 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreHeaderParsing = new Regex(MicrosoftAspNetCoreHeaderParsingPattern, RegexOptions.Compiled); |
| 79 | +#endif |
| 80 | + |
| 81 | + /// <summary> |
| 82 | + /// Matches the built in Microsoft.AspNetCore.Server.Kestrel metrics |
| 83 | + /// </summary> |
| 84 | +#if NET8_0_OR_GREATER |
| 85 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreServerKestrel = MicrosoftAspNetCoreServerKestrelRegex(); |
| 86 | + |
| 87 | + [GeneratedRegex(MicrosoftAspNetCoreServerKestrelPattern, RegexOptions.Compiled)] |
| 88 | + private static partial Regex MicrosoftAspNetCoreServerKestrelRegex(); |
| 89 | +#else |
| 90 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreServerKestrel = new Regex(MicrosoftAspNetCoreServerKestrelPattern, RegexOptions.Compiled); |
| 91 | +#endif |
| 92 | + |
| 93 | + /// <summary> |
| 94 | + /// Matches the built in Microsoft.AspNetCore.Http.Connections metrics |
| 95 | + /// </summary> |
| 96 | +#if NET8_0_OR_GREATER |
| 97 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreHttpConnections = MicrosoftAspNetCoreHttpConnectionsRegex(); |
| 98 | + |
| 99 | + [GeneratedRegex(MicrosoftAspNetCoreHttpConnectionsPattern, RegexOptions.Compiled)] |
| 100 | + private static partial Regex MicrosoftAspNetCoreHttpConnectionsRegex(); |
| 101 | +#else |
| 102 | + public static readonly SubstringOrRegexPattern MicrosoftAspNetCoreHttpConnections = new Regex(MicrosoftAspNetCoreHttpConnectionsPattern, RegexOptions.Compiled); |
| 103 | +#endif |
| 104 | + |
| 105 | + /// <summary> |
| 106 | + /// Matches the built in Microsoft.Extensions.Diagnostics.HealthChecks metrics |
| 107 | + /// </summary> |
| 108 | +#if NET8_0_OR_GREATER |
| 109 | + public static readonly SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsHealthChecks = MicrosoftExtensionsDiagnosticsHealthChecksRegex(); |
| 110 | + |
| 111 | + [GeneratedRegex(MicrosoftExtensionsDiagnosticsHealthChecksPattern, RegexOptions.Compiled)] |
| 112 | + private static partial Regex MicrosoftExtensionsDiagnosticsHealthChecksRegex(); |
| 113 | +#else |
| 114 | + public static readonly SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsHealthChecks = new Regex(MicrosoftExtensionsDiagnosticsHealthChecksPattern, RegexOptions.Compiled); |
| 115 | +#endif |
| 116 | + |
| 117 | + /// <summary> |
| 118 | + /// Matches the built in Microsoft.Extensions.Diagnostics.ResourceMonitoring metrics |
| 119 | + /// </summary> |
| 120 | +#if NET8_0_OR_GREATER |
| 121 | + public static readonly SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsResourceMonitoring = MicrosoftExtensionsDiagnosticsResourceMonitoringRegex(); |
| 122 | + |
| 123 | + [GeneratedRegex(MicrosoftExtensionsDiagnosticsResourceMonitoringPattern, RegexOptions.Compiled)] |
| 124 | + private static partial Regex MicrosoftExtensionsDiagnosticsResourceMonitoringRegex(); |
| 125 | +#else |
| 126 | + public static readonly SubstringOrRegexPattern MicrosoftExtensionsDiagnosticsResourceMonitoring = new Regex(MicrosoftExtensionsDiagnosticsResourceMonitoringPattern, RegexOptions.Compiled); |
| 127 | +#endif |
| 128 | + |
| 129 | + /// <summary> |
| 130 | + /// Matches the built in System.Net.NameResolution metrics |
| 131 | + /// </summary> |
| 132 | +#if NET8_0_OR_GREATER |
| 133 | + public static readonly SubstringOrRegexPattern SystemNetNameResolution = SystemNetNameResolutionRegex(); |
| 134 | + |
| 135 | + [GeneratedRegex(SystemNetNameResolutionPattern, RegexOptions.Compiled)] |
| 136 | + private static partial Regex SystemNetNameResolutionRegex(); |
| 137 | +#else |
| 138 | + public static readonly SubstringOrRegexPattern SystemNetNameResolution = new Regex(SystemNetNameResolutionPattern, RegexOptions.Compiled); |
| 139 | +#endif |
| 140 | + |
| 141 | + /// <summary> |
| 142 | + /// Matches the built in <see cref="System.Net.Http"/> metrics |
| 143 | + /// </summary> |
| 144 | +#if NET8_0_OR_GREATER |
| 145 | + public static readonly SubstringOrRegexPattern SystemNetHttp = SystemNetHttpRegex(); |
| 146 | + |
| 147 | + [GeneratedRegex(SystemNetHttpPattern, RegexOptions.Compiled)] |
| 148 | + private static partial Regex SystemNetHttpRegex(); |
| 149 | +#else |
| 150 | + public static readonly SubstringOrRegexPattern SystemNetHttp = new Regex(SystemNetHttpPattern, RegexOptions.Compiled); |
| 151 | +#endif |
| 152 | + |
| 153 | + private static readonly Lazy<IList<SubstringOrRegexPattern>> LazyAll = new(() => new List<SubstringOrRegexPattern> |
| 154 | + { |
| 155 | + MicrosoftAspNetCoreHosting, |
| 156 | + MicrosoftAspNetCoreRouting, |
| 157 | + MicrosoftAspNetCoreDiagnostics, |
| 158 | + MicrosoftAspNetCoreRateLimiting, |
| 159 | + MicrosoftAspNetCoreHeaderParsing, |
| 160 | + MicrosoftAspNetCoreServerKestrel, |
| 161 | + MicrosoftAspNetCoreHttpConnections, |
| 162 | + SystemNetNameResolution, |
| 163 | + SystemNetHttp, |
| 164 | + MicrosoftExtensionsDiagnosticsHealthChecks, |
| 165 | + MicrosoftExtensionsDiagnosticsResourceMonitoring |
| 166 | + }); |
| 167 | + |
| 168 | + /// <summary> |
| 169 | + /// Matches all built in metrics |
| 170 | + /// </summary> |
| 171 | + /// <returns></returns> |
| 172 | + public static IList<SubstringOrRegexPattern> All => LazyAll.Value; |
| 173 | +} |
0 commit comments