@@ -87,7 +87,7 @@ async Task addMetric(string metricName, string[] tags)
87
87
var tagDict = tags ? . ToDictionary ( t => t , _ => "*" ) ;
88
88
var apiResult = await GetMetric ( metricName , result . StartTime , tags : tagDict ) ;
89
89
if ( apiResult == null ) return ;
90
- if ( tags ? . Any ( ) ?? false )
90
+ if ( tags ? . Length > 0 )
91
91
{
92
92
result . MultiSeries [ metricName ] = apiResult . Series
93
93
. GroupBy ( s => s . Host )
@@ -171,15 +171,14 @@ public static class TagValues
171
171
public static class TagCombos
172
172
{
173
173
public static readonly Dictionary < string , string >
174
- AllNetDirections = new Dictionary < string , string > { [ Tags . Direction ] = "*" } ,
175
- AllDisks = new Dictionary < string , string > { [ Tags . Disk ] = "*" } ;
174
+ AllNetDirections = new ( ) { [ Tags . Direction ] = "*" } ,
175
+ AllDisks = new ( ) { [ Tags . Disk ] = "*" } ;
176
176
177
- public static Dictionary < string , string > AllDirectionsForInterface ( string ifaceId )
178
- => new Dictionary < string , string >
179
- {
180
- [ Tags . Direction ] = "*" ,
181
- [ Tags . IFace ] = ifaceId
182
- } ;
177
+ public static Dictionary < string , string > AllDirectionsForInterface ( string ifaceId ) => new ( )
178
+ {
179
+ [ Tags . Direction ] = "*" ,
180
+ [ Tags . IFace ] = ifaceId
181
+ } ;
183
182
}
184
183
185
184
public static bool IsCounter ( string metric , string host )
@@ -189,18 +188,11 @@ public static bool IsCounter(string metric, string host)
189
188
{
190
189
metric = metric . Replace ( $ "__{ host } .", "" ) ;
191
190
}
192
- switch ( metric )
191
+ return metric switch
193
192
{
194
- case Globals . CPU :
195
- case Globals . NetBytes :
196
- case Globals . NetBondBytes :
197
- case Globals . NetOtherBytes :
198
- case Globals . NetTunnelBytes :
199
- case Globals . NetVirtualBytes :
200
- return true ;
201
- default :
202
- return false ;
203
- }
193
+ Globals . CPU or Globals . NetBytes or Globals . NetBondBytes or Globals . NetOtherBytes or Globals . NetTunnelBytes or Globals . NetVirtualBytes => true ,
194
+ _ => false ,
195
+ } ;
204
196
}
205
197
206
198
public static string InterfaceMetricName ( Interface i ) =>
@@ -215,7 +207,7 @@ public static string InterfaceMetricName(Interface i) =>
215
207
216
208
public static string GetDenormalized ( string metric , string host , Dictionary < string , List < string > > metricCache )
217
209
{
218
- if ( host == null || host . Contains ( "*" ) || host . Contains ( "|" ) )
210
+ if ( host == null || host . Contains ( '*' ) || host . Contains ( '|' ) )
219
211
{
220
212
return metric ;
221
213
}
@@ -264,17 +256,17 @@ public class BosunMetricResponse
264
256
/// </summary>
265
257
public class PointSeries
266
258
{
267
- private static readonly Regex HostRegex = new Regex ( @"\{host=(.*)[,|\}]" , RegexOptions . Compiled ) ;
259
+ private static readonly Regex HostRegex = new ( @"\{host=(.*)[,|\}]" , RegexOptions . Compiled ) ;
268
260
private string _host ;
269
261
public string Host
270
262
{
271
263
get
272
264
{
273
265
if ( _host == null )
274
266
{
275
- if ( Tags . ContainsKey ( "host" ) )
267
+ if ( Tags . TryGetValue ( "host" , out string value ) )
276
268
{
277
- Host = Tags [ "host" ] ;
269
+ Host = value ;
278
270
}
279
271
else
280
272
{
0 commit comments