Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Prometheus lib 1.x #7880

Merged
merged 28 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0e7db5f
Consolidate all metric collectors into the metrics system
fab-10 Nov 13, 2024
695a53a
Fixes
fab-10 Nov 13, 2024
5095e68
Do not recreate the Prometheus metric system
fab-10 Nov 14, 2024
a4d09ae
Bump opentelemetry dependencies
fab-10 Jan 3, 2024
a7d8131
Upgrade to Promethus java client 1.x and adapt the code to the new ve…
fab-10 Jan 18, 2024
43770b4
Upgrade Promethus lib to 1.x and adapt the code to the new version
fab-10 Nov 13, 2024
ea3b2e3
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 19, 2024
d8ffff4
Add support for counter metric with external supplied value
fab-10 Nov 20, 2024
70b767c
Merge branch 'labelled-supplied-metric' into upgrade-prometheus-1.x
fab-10 Nov 20, 2024
1610025
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 20, 2024
7281076
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 21, 2024
0405e2c
Update CHANGELOG
fab-10 Nov 21, 2024
539dc5d
Clean verification metadata
fab-10 Nov 21, 2024
5a577d2
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 22, 2024
f6c79cc
Create a unique key for cached metric maps
fab-10 Nov 22, 2024
f343ce5
Correct other counters that were created as gauges
fab-10 Nov 22, 2024
306a140
Rename ExtranalSummary to SuppliedSummary for consistency
fab-10 Nov 22, 2024
b76bdee
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 25, 2024
66eaa69
Push up some common collectors methods
fab-10 Nov 25, 2024
187ff9b
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 25, 2024
fd9f323
Revert "Push up some common collectors methods"
fab-10 Nov 25, 2024
a58c2cc
Fix tests
fab-10 Nov 25, 2024
ffc7907
Improve javadoc
fab-10 Nov 25, 2024
1c2da80
Fixes
fab-10 Nov 25, 2024
4a74167
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 26, 2024
2d75538
o.prometheus:prometheus-metrics-bom:1.3.4
fab-10 Nov 26, 2024
9d7011a
Update CHANGELOG.md
fab-10 Nov 27, 2024
6ccc049
Merge branch 'main' into upgrade-prometheus-1.x
fab-10 Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@

### Breaking Changes
- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783)
- With the upgrade of the Prometheus Java Metrics library, there are the following changes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some projects (eg teku) that use metrics core modules - need to communicate breaking changes to them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will support them for the upgrade

- Gauge names are not allowed to end with `total`, therefore the metric `besu_blockchain_difficulty_total` is losing the `_total` suffix
- The `_created` timestamps are not returned by default, you can set the env var `BESU_OPTS="-Dio.prometheus.exporter.includeCreatedTimestamps=true"` to enabled them
fab-10 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are either of these metrics used on the Besu full dashboard?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they are not used by our official dashboard

- Some JVM metrics have changed name to adhere to the OTEL standard (see the table below), [Besu Full Grafana dashboard](https://grafana.com/grafana/dashboards/16455-besu-full/) is updated to support both names
Copy link
Contributor

@siladu siladu Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great there's a dashboard update to go along with this 👍 . For completeness and extra visibility can you also mention this in the PR desc please?
I think we should also call it out in the release notes and when we announce on socials.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the description


| Old Name | New Name |
|---------------------------------|---------------------------------|
| jvm_memory_bytes_committed | jvm_memory_committed_bytes |
| jvm_memory_bytes_init | jvm_memory_init_bytes |
| jvm_memory_bytes_max | jvm_memory_max_bytes |
| jvm_memory_bytes_used | jvm_memory_used_bytes |
| jvm_memory_pool_bytes_committed | jvm_memory_pool_committed_bytes |
| jvm_memory_pool_bytes_init | jvm_memory_pool_init_bytes |
| jvm_memory_pool_bytes_max | jvm_memory_pool_max_bytes |
| jvm_memory_pool_bytes_used | jvm_memory_pool_used_bytes |

### Upcoming Breaking Changes
- Plugin API will be deprecating the BesuContext interface to be replaced with the ServiceManager interface.
Expand All @@ -26,6 +41,7 @@
- Add a method to check if a metric category is enabled to the plugin API [#7832](https://github.com/hyperledger/besu/pull/7832)
- Add a new metric collector for counters which get their value from suppliers [#7894](https://github.com/hyperledger/besu/pull/7894)
- Add account and state overrides to `eth_call` [#7801](https://github.com/hyperledger/besu/pull/7801) and `eth_estimateGas` [#7890](https://github.com/hyperledger/besu/pull/7890)
- Prometheus Java Metrics library upgraded to version 1.3.3 [#7880](https://github.com/hyperledger/besu/pull/7880)

### Bug fixes
- Fix registering new metric categories from plugins [#7825](https://github.com/hyperledger/besu/pull/7825)
Expand Down
8 changes: 3 additions & 5 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,7 @@ public Runner build() {
subscriptionManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());
}

final Optional<MetricsService> metricsService =
createMetricsService(vertx, metricsConfiguration);
final Optional<MetricsService> metricsService = createMetricsService(metricsConfiguration);

final Optional<EthStatsService> ethStatsService;
if (isEthStatsEnabled()) {
Expand Down Expand Up @@ -1469,9 +1468,8 @@ private WebSocketService createWebsocketService(
vertx, configuration, websocketMessageHandler, authenticationService, metricsSystem);
}

private Optional<MetricsService> createMetricsService(
final Vertx vertx, final MetricsConfiguration configuration) {
return MetricsService.create(vertx, configuration, metricsSystem);
private Optional<MetricsService> createMetricsService(final MetricsConfiguration configuration) {
return MetricsService.create(configuration, metricsSystem);
fab-10 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import java.util.function.Function;
import java.util.function.Supplier;

import io.vertx.core.Vertx;
import jakarta.validation.constraints.NotBlank;
import org.apache.tuweni.bytes.Bytes;
import org.slf4j.Logger;
Expand Down Expand Up @@ -458,8 +457,7 @@ private static Optional<MetricsService> initMetrics(final BlocksSubCommand paren
parentCommand.parentCommand.metricsConfiguration();

Optional<MetricsService> metricsService =
MetricsService.create(
Vertx.vertx(), metricsConfiguration, parentCommand.parentCommand.getMetricsSystem());
MetricsService.create(metricsConfiguration, parentCommand.parentCommand.getMetricsSystem());
metricsService.ifPresent(MetricsService::start);
return metricsService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
private void addObservation(
final Map<String, Object> observations, final Observation observation) {
final Map<String, Object> categoryObservations =
getNextMapLevel(observations, observation.getCategory().getName());
if (observation.getLabels().isEmpty()) {
categoryObservations.put(observation.getMetricName(), observation.getValue());
getNextMapLevel(observations, observation.category().getName());
if (observation.labels().isEmpty()) {
categoryObservations.put(observation.metricName(), observation.value());
} else {
addLabelledObservation(categoryObservations, observation);
}
}

private void addLabelledObservation(
final Map<String, Object> categoryObservations, final Observation observation) {
final List<String> labels = observation.getLabels();
Map<String, Object> values = getNextMapLevel(categoryObservations, observation.getMetricName());
final List<String> labels = observation.labels();
Map<String, Object> values = getNextMapLevel(categoryObservations, observation.metricName());
for (int i = 0; i < labels.size() - 1; i++) {
values = getNextMapLevel(values, labels.get(i));
}
values.put(labels.get(labels.size() - 1), observation.getValue());
values.put(labels.get(labels.size() - 1), observation.value());
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void createGauges(final MetricsSystem metricsSystem) {

metricsSystem.createGauge(
BLOCKCHAIN,
"difficulty_total",
"difficulty",
"Total difficulty of the chainhead",
() -> this.getChainHead().getTotalDifficulty().toBigInteger().doubleValue());

Expand Down
Loading