@@ -44,17 +44,17 @@ public class ClientSettingsFactory : IClientSettingsFactory
44
44
private readonly Counter _settingsRefreshCounter = Metrics . CreateCounter (
45
45
"rbx_client_settings_refresh" ,
46
46
"Number of times the client settings have been refreshed." ,
47
- "mount" , "path "
47
+ "application "
48
48
) ;
49
49
private readonly Counter _settingsWriteCounter = Metrics . CreateCounter (
50
50
"rbx_client_settings_write" ,
51
51
"Number of times the client settings have been written." ,
52
- "mount" , "path "
52
+ "application "
53
53
) ;
54
54
private readonly Counter _settingsReadCounter = Metrics . CreateCounter (
55
55
"rbx_client_settings_read" ,
56
56
"Number of times the client settings have been read." ,
57
- "mount" , "path "
57
+ "application "
58
58
) ;
59
59
60
60
@@ -264,7 +264,7 @@ private Dictionary<string, object> ParseSecrets(Secrets secrets, MetaData metada
264
264
private void DoCommit ( string applicationName , Secrets data , MetaData metadata )
265
265
{
266
266
var serializedData = data . ToDictionary ( k => k . Key , v => v . Value . ToString ( ) ) ;
267
- _settingsWriteCounter . WithLabels ( _mount , _path ) . Inc ( ) ;
267
+ _settingsWriteCounter . WithLabels ( applicationName ) . Inc ( ) ;
268
268
269
269
if ( _settings . ClientSettingsViaVault )
270
270
{
@@ -299,7 +299,6 @@ _client.V1.Secrets.KeyValue.V2 .WriteSecretAsync(
299
299
private IDictionary < string , Secrets > DoRefresh ( IDictionary < string , Secrets > oldSettings )
300
300
{
301
301
_logger ? . Debug ( "Refreshing settings, FromVault = {0}" , _settings . ClientSettingsViaVault ) ;
302
- _settingsRefreshCounter . WithLabels ( _mount , _path ) . Inc ( ) ;
303
302
304
303
var settings = new Dictionary < string , Secrets > ( ) ;
305
304
@@ -311,6 +310,8 @@ private IDictionary<string, Secrets> DoRefresh(IDictionary<string, Secrets> oldS
311
310
// For each key, read the secret
312
311
foreach ( var ( applicationName , applicationData , applicationMetaData ) in data )
313
312
{
313
+ _settingsRefreshCounter . WithLabels ( applicationName ) . Inc ( ) ;
314
+
314
315
var parsedSecrets = ParseSecrets ( applicationData , applicationMetaData ) ;
315
316
settings . Add ( applicationName , parsedSecrets ) ;
316
317
}
@@ -348,16 +349,7 @@ public IDictionary<string, Secrets> RawSettings
348
349
/// <inheritdoc cref="IClientSettingsFactory.Refresh"/>
349
350
public void Refresh ( )
350
351
{
351
- _settingsCacheLock . EnterWriteLock ( ) ;
352
-
353
- try
354
- {
355
- _settingsCacheRefreshAhead . LazyValue . Refresh ( ) ;
356
- }
357
- finally
358
- {
359
- _settingsCacheLock . ExitWriteLock ( ) ;
360
- }
352
+ _settingsCacheRefreshAhead . LazyValue . Refresh ( ) ;
361
353
}
362
354
363
355
/// <inheritdoc cref="IClientSettingsFactory.GetSettingsForApplication(string, bool)"/>
@@ -368,7 +360,7 @@ public Secrets GetSettingsForApplication(string application, bool withDependenci
368
360
369
361
_settingsCacheLock . EnterReadLock ( ) ;
370
362
371
- _settingsReadCounter . WithLabels ( _mount , _path ) . Inc ( ) ;
363
+ _settingsReadCounter . WithLabels ( application ) . Inc ( ) ;
372
364
373
365
try
374
366
{
@@ -438,13 +430,11 @@ public T GetSettingForApplication<T>(string application, string setting, bool wi
438
430
439
431
try
440
432
{
441
- var str = ( ( JsonElement ) value ) . GetString ( ) ;
442
-
443
433
return typeof ( T ) switch
444
434
{
445
- Type t when t == typeof ( string ) => ( T ) ( object ) str . ToString ( ) ,
446
- Type t when t == typeof ( bool ) => ( T ) ( object ) bool . Parse ( str ) ,
447
- Type t when t == typeof ( int ) => ( T ) ( object ) long . Parse ( str ) ,
435
+ Type t when t == typeof ( string ) => ( T ) ( object ) value . ToString ( ) ,
436
+ Type t when t == typeof ( bool ) => ( T ) value ,
437
+ Type t when t == typeof ( int ) => ( T ) value ,
448
438
_ => throw new ArgumentException ( string . Format ( "'{0}' is not a supported type!" , typeof ( T ) . Name ) ) ,
449
439
} ;
450
440
}
0 commit comments