11// Copyright The OpenTelemetry Authors
22// SPDX-License-Identifier: Apache-2.0
33
4+ #if NET
5+ using System . Collections . Frozen ;
6+ #endif
47using System . Diagnostics . Metrics ;
58
69namespace OpenTelemetry . Metrics ;
@@ -18,7 +21,13 @@ public sealed class Metric
1821
1922 // Short default histogram bounds. Based on the recommended semantic convention values for http.server.request.duration.
2023 internal static readonly double [ ] DefaultHistogramBoundsShortSeconds = new double [ ] { 0.005 , 0.01 , 0.025 , 0.05 , 0.075 , 0.1 , 0.25 , 0.5 , 0.75 , 1 , 2.5 , 5 , 7.5 , 10 } ;
21- internal static readonly HashSet < ( string , string ) > DefaultHistogramBoundShortMappings = new ( )
24+ internal static readonly
25+ #if NET
26+ FrozenSet < ( string , string ) >
27+ #else
28+ HashSet< ( string , string ) >
29+ #endif
30+ DefaultHistogramBoundShortMappings = new HashSet < ( string , string ) >
2231 {
2332 ( "Microsoft.AspNetCore.Hosting" , "http.server.request.duration" ) ,
2433 ( "Microsoft.AspNetCore.RateLimiting" , "aspnetcore.rate_limiting.request.time_in_queue" ) ,
@@ -30,16 +39,30 @@ public sealed class Metric
3039 ( "System.Net.Http" , "http.client.request.duration" ) ,
3140 ( "System.Net.Http" , "http.client.request.time_in_queue" ) ,
3241 ( "System.Net.NameResolution" , "dns.lookup.duration" ) ,
33- } ;
42+ }
43+ #if NET
44+ . ToFrozenSet ( )
45+ #endif
46+ ;
3447
3548 // Long default histogram bounds. Not based on a standard. May change in the future.
3649 internal static readonly double[ ] DefaultHistogramBoundsLongSeconds = new double [ ] { 0.01 , 0.02 , 0.05 , 0.1 , 0.2 , 0.5 , 1 , 2 , 5 , 10 , 30 , 60 , 120 , 300 } ;
37- internal static readonly HashSet < ( string , string ) > DefaultHistogramBoundLongMappings = new ( )
50+ internal static readonly
51+ #if NET
52+ FrozenSet < ( string , string ) >
53+ #else
54+ HashSet< ( string , string ) >
55+ #endif
56+ DefaultHistogramBoundLongMappings = new HashSet < ( string , string ) >
3857 {
3958 ( "Microsoft.AspNetCore.Http.Connections" , "signalr.server.connection.duration" ) ,
4059 ( "Microsoft.AspNetCore.Server.Kestrel" , "kestrel.connection.duration" ) ,
4160 ( "System.Net.Http" , "http.client.connection.duration" ) ,
42- } ;
61+ }
62+ #if NET
63+ . ToFrozenSet ( )
64+ #endif
65+ ;
4366
4467 internal readonly AggregatorStore AggregatorStore ;
4568
0 commit comments