Skip to content

Commit

Permalink
better Java
Browse files Browse the repository at this point in the history
  • Loading branch information
justinstoller committed Sep 26, 2024
1 parent 412f23b commit c3f314e
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/java/com/puppetlabs/puppetserver/MetricsPuppetProfiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ private String safeGet(String[] collection, int i) {
}
}

private String metricify(String ...ids) {
String base = ids[0];
List<String> idList = Arrays.asList(ids);
for(String s : idList.subList(1, idList.size())) {
base.concat(".").concat(s);
}
return base;
}

private void updateMetricsTrackers(String[] metricId, Map<String, Timer> metricsByID) {
String firstElement = safeGet(metricId, 0);
String secondElement = safeGet(metricId, 1);
Expand Down Expand Up @@ -149,7 +140,7 @@ private void updateMetricsTrackers(String[] metricId, Map<String, Timer> metrics
("catalog".equals(secondElement) && "munge".equals(thirdElemet)) ||
("report".equals(secondElement) && "convert_to_wire_format_hash".equals(thirdElemet))
) {
String key = metricify(secondElement, thirdElemet);
String key = String.join(".", secondElement, thirdElemet);
Timer metric = metricsByID.get(getMetricName(sliceOfArrayToList(metricId, 3)));
this.puppetdb_timers.put(key, metric);

Expand All @@ -161,7 +152,7 @@ private void updateMetricsTrackers(String[] metricId, Map<String, Timer> metrics
"replace facts".equals(fourthElement) ||
"replace catalog".equals(fourthElement)
) {
String key = metricify(secondElement, thirdElemet, fourthElement);
String key = String.join(".", secondElement, thirdElemet, fourthElement);
Timer metric = metricsByID.get(getMetricName(sliceOfArrayToList(metricId, 4)));
this.puppetdb_timers.put(key, metric);
}
Expand Down

0 comments on commit c3f314e

Please sign in to comment.