22
22
import com .google .common .collect .ImmutableMap ;
23
23
import java .util .Collection ;
24
24
import java .util .Collections ;
25
+ import java .util .HashMap ;
25
26
import java .util .HashSet ;
26
27
import java .util .List ;
27
28
import java .util .Map ;
@@ -236,13 +237,8 @@ public void addTimedValue(final String key, final T timer, final long duration,
236
237
*/
237
238
private void addValueToTimer (String fullTimerName , String simplifiedTimerName , final long duration ,
238
239
final TimeUnit timeUnit , Map <String , String > attributes ) {
239
- Map <String , String > fullAttributes = ImmutableMap .<String , String >builder ()
240
- .putAll (attributes )
241
- .put (MetricAttributeConstants .PINOT_METRIC_NAME , fullTimerName )
242
- .build ();
243
-
244
240
final PinotMetricName metricName = PinotMetricUtils .makePinotMetricName (_clazz , fullTimerName ,
245
- simplifiedTimerName , fullAttributes );
241
+ simplifiedTimerName , new HashMap <>( attributes ) );
246
242
PinotTimer timer =
247
243
PinotMetricUtils .makePinotTimer (_metricsRegistry , metricName , TimeUnit .MILLISECONDS , TimeUnit .SECONDS );
248
244
if (timer != null ) {
@@ -366,10 +362,9 @@ public PinotMeter addMeteredTableValue(final String tableName, final String key,
366
362
PinotMeter reusedMeter , Map <String , String > attributes ) {
367
363
String meterName = meter .getMeterName ();
368
364
final String fullMeterName = _metricPrefix + getTableName (tableName ) + "." + key + "." + meterName ;
369
- Map <String , String > fullAttributes = ImmutableMap .<String , String >builder ()
370
- .putAll (attributes )
371
- .put (MetricAttributeConstants .TABLE_NAME , tableName )
372
- .build ();
365
+ Map <String , String > fullAttributes = new HashMap <>(attributes );
366
+ fullAttributes .put (MetricAttributeConstants .TABLE_NAME , tableName );
367
+
373
368
return addValueToMeter (fullMeterName , meterName , meter .getUnit (), unitCount , reusedMeter , fullAttributes );
374
369
}
375
370
@@ -392,13 +387,8 @@ private PinotMeter addValueToMeter(
392
387
reusedMeter .mark (unitCount );
393
388
return reusedMeter ;
394
389
} else {
395
- Map <String , String > fullAttributes = ImmutableMap .<String , String >builder ()
396
- .putAll (attributes )
397
- .put (MetricAttributeConstants .PINOT_METRIC_NAME , fullMeterName )
398
- .build ();
399
-
400
390
final PinotMetricName metricName = PinotMetricUtils .makePinotMetricName (_clazz , fullMeterName ,
401
- simplifiedMeterName , fullAttributes );
391
+ simplifiedMeterName , new HashMap <>( attributes ) );
402
392
403
393
final PinotMeter newMeter =
404
394
PinotMetricUtils .makePinotMeter (_metricsRegistry , metricName , unit , TimeUnit .SECONDS );
@@ -688,12 +678,8 @@ public void addCallbackGauge(final String metricName,
688
678
String simplifiedMetricName ,
689
679
Map <String , String > attributes ,
690
680
final Callable <Long > valueCallback ) {
691
- Map <String , String > fullAttributes = ImmutableMap .<String , String >builder ()
692
- .putAll (attributes )
693
- .put (MetricAttributeConstants .PINOT_METRIC_NAME , metricName )
694
- .build ();
695
681
PinotMetricName pinotMetricName = PinotMetricUtils .makePinotMetricName (_clazz , _metricPrefix + metricName ,
696
- simplifiedMetricName , fullAttributes );
682
+ simplifiedMetricName , new HashMap <>( attributes ) );
697
683
698
684
PinotMetricUtils
699
685
.makeGauge (_metricsRegistry , pinotMetricName ,
@@ -737,10 +723,8 @@ public void setOrUpdateTableGauge(final String tableName, final String key, fina
737
723
Map <String , String > attributes , final Supplier <Long > valueSupplier ) {
738
724
String fullGaugeName = composeTableGaugeName (tableName , key , gauge );
739
725
740
- Map <String , String > fullAttributes = ImmutableMap .<String , String >builder ()
741
- .putAll (attributes )
742
- .put (MetricAttributeConstants .TABLE_NAME , tableName )
743
- .build ();
726
+ Map <String , String > fullAttributes = new HashMap <>(attributes );
727
+ fullAttributes .put (MetricAttributeConstants .TABLE_NAME , tableName );
744
728
745
729
setOrUpdateGauge (fullGaugeName , gauge .getGaugeName (), fullAttributes , valueSupplier ::get );
746
730
}
@@ -820,13 +804,8 @@ public void setOrUpdateGlobalGauge(final String metricName, final LongSupplier v
820
804
821
805
public void setOrUpdateGauge (final String metricName , final String simplifiedMetricName ,
822
806
Map <String , String > attributes , final LongSupplier valueSupplier ) {
823
- Map <String , String > fullAttributes = ImmutableMap .<String , String >builder ()
824
- .putAll (attributes )
825
- .put (MetricAttributeConstants .PINOT_METRIC_NAME , metricName )
826
- .build ();
827
-
828
807
PinotMetricName pinotMetricName = PinotMetricUtils .makePinotMetricName (_clazz , _metricPrefix + metricName ,
829
- simplifiedMetricName , fullAttributes );
808
+ simplifiedMetricName , new HashMap <>( attributes ) );
830
809
831
810
PinotGauge <Long > pinotGauge = PinotMetricUtils .makeGauge (_metricsRegistry , pinotMetricName ,
832
811
PinotMetricUtils .makePinotGauge (pinotMetricName , avoid -> valueSupplier .getAsLong ()));
0 commit comments