private void addMetric ( List < Metric > metrics , String name , TagList tags , Object value ) { long now = System . currentTimeMillis ( ) ; if ( onlyNumericMetrics ) { value = asNumber ( value ) ; } if ( value != null ) { TagList newTags = counters . matches ( MonitorConfig . builder ( name ) . withTags ( tags ) . build ( ) ) ? getTagListWithAdditionalTag ( tags , DataSourceType . COUNTER ) : getTagListWithAdditionalTag ( tags , DataSourceType . GAUGE ) ; Metric m = new Metric ( name , newTags , now , value ) ; metrics . add ( m ) ; } }
Create a new metric object and add it to the list .