@@ -91,11 +91,11 @@ void IMetrics.AddMetric(string key, double value, MetricUnit unit, MetricResolut
9191 {
9292 if ( string . IsNullOrWhiteSpace ( key ) )
9393 throw new ArgumentNullException (
94- $ "'AddMetric' method requires a valid metrics key. 'Null' or empty values are not allowed.") ;
94+ nameof ( key ) , "'AddMetric' method requires a valid metrics key. 'Null' or empty values are not allowed." ) ;
9595
9696 if ( value < 0 ) {
9797 throw new ArgumentException (
98- "'AddMetric' method requires a valid metrics value. Value must be >= 0." ) ;
98+ "'AddMetric' method requires a valid metrics value. Value must be >= 0." , nameof ( value ) ) ;
9999 }
100100
101101 var metrics = _context . GetMetrics ( ) ;
@@ -150,8 +150,8 @@ string IMetrics.GetService()
150150 void IMetrics . AddDimension ( string key , string value )
151151 {
152152 if ( string . IsNullOrWhiteSpace ( key ) )
153- throw new ArgumentNullException (
154- $ "'AddDimension' method requires a valid dimension key. 'Null' or empty values are not allowed.") ;
153+ throw new ArgumentNullException ( nameof ( key ) ,
154+ "'AddDimension' method requires a valid dimension key. 'Null' or empty values are not allowed." ) ;
155155
156156 _context . AddDimension ( key , value ) ;
157157 }
@@ -168,8 +168,8 @@ void IMetrics.AddDimension(string key, string value)
168168 void IMetrics . AddMetadata ( string key , object value )
169169 {
170170 if ( string . IsNullOrWhiteSpace ( key ) )
171- throw new ArgumentNullException (
172- $ "'AddMetadata' method requires a valid metadata key. 'Null' or empty values are not allowed.") ;
171+ throw new ArgumentNullException ( nameof ( key ) ,
172+ "'AddMetadata' method requires a valid metadata key. 'Null' or empty values are not allowed." ) ;
173173
174174 _context . AddMetadata ( key , value ) ;
175175 }
@@ -186,8 +186,8 @@ void IMetrics.SetDefaultDimensions(Dictionary<string, string> defaultDimension)
186186 {
187187 foreach ( var item in defaultDimension )
188188 if ( string . IsNullOrWhiteSpace ( item . Key ) || string . IsNullOrWhiteSpace ( item . Value ) )
189- throw new ArgumentNullException (
190- $ "'SetDefaultDimensions' method requires a valid key pair. 'Null' or empty values are not allowed.") ;
189+ throw new ArgumentNullException ( nameof ( item . Key ) ,
190+ "'SetDefaultDimensions' method requires a valid key pair. 'Null' or empty values are not allowed." ) ;
191191
192192 _context . SetDefaultDimensions ( DictionaryToList ( defaultDimension ) ) ;
193193 }
@@ -258,8 +258,8 @@ void IMetrics.PushSingleMetric(string metricName, double value, MetricUnit unit,
258258 Dictionary < string , string > defaultDimensions , MetricResolution metricResolution )
259259 {
260260 if ( string . IsNullOrWhiteSpace ( metricName ) )
261- throw new ArgumentNullException (
262- $ "'PushSingleMetric' method requires a valid metrics key. 'Null' or empty values are not allowed.") ;
261+ throw new ArgumentNullException ( nameof ( metricName ) ,
262+ "'PushSingleMetric' method requires a valid metrics key. 'Null' or empty values are not allowed." ) ;
263263
264264 using var context = InitializeContext ( nameSpace , service , defaultDimensions ) ;
265265 context . AddMetric ( metricName , value , unit , metricResolution ) ;
0 commit comments