forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to Promethus java client 1.x and adapt the code to the new ve…
…rsion Signed-off-by: Fabio Di Fabio <[email protected]>
- Loading branch information
Showing
15 changed files
with
1,004 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...src/main/java/org/hyperledger/besu/metrics/prometheus/CategorizedPrometheusCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.hyperledger.besu.metrics.prometheus; | ||
|
||
import io.prometheus.metrics.model.snapshots.Label; | ||
import io.prometheus.metrics.model.snapshots.Labels; | ||
import org.hyperledger.besu.plugin.services.metrics.MetricCategory; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public abstract class CategorizedPrometheusCollector implements PrometheusCollector { | ||
protected final MetricCategory category; | ||
protected final String name; | ||
protected final String prefixedName; | ||
|
||
protected CategorizedPrometheusCollector(final MetricCategory category, final String name) { | ||
this.category = category; | ||
this.name = name; | ||
this.prefixedName = prefixedName(category, name); | ||
} | ||
|
||
private static String categoryPrefix(final MetricCategory category) { | ||
return category.getApplicationPrefix().orElse("") + category.getName() + "_"; | ||
} | ||
|
||
/** | ||
* Get the category prefixed name. | ||
* | ||
* @return the name as string | ||
*/ | ||
private static String prefixedName(final MetricCategory category, final String name) { | ||
return categoryPrefix(category) + name; | ||
} | ||
|
||
protected static List<String> getLabelValues(final Labels labels) { | ||
return labels.stream().map(Label::getValue).collect(Collectors.toList()); | ||
} | ||
} |
59 changes: 0 additions & 59 deletions
59
...ics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/CurrentValueCollector.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/PrometheusCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.hyperledger.besu.metrics.prometheus; | ||
|
||
import io.prometheus.metrics.model.registry.Collector; | ||
import org.hyperledger.besu.metrics.Observation; | ||
import org.hyperledger.besu.plugin.services.metrics.MetricCategory; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public interface PrometheusCollector { | ||
String getName(); | ||
|
||
Collector toCollector(); | ||
|
||
Stream<Observation> streamObservations(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.