|
29 | 29 | import org.apache.logging.log4j.Logger; |
30 | 30 | import org.apache.tuweni.bytes.Bytes32; |
31 | 31 | import org.hyperledger.besu.plugin.services.MetricsSystem; |
| 32 | +import org.hyperledger.besu.plugin.services.metrics.Counter; |
| 33 | +import org.hyperledger.besu.plugin.services.metrics.LabelledMetric; |
32 | 34 | import tech.pegasys.teku.bls.BLSPublicKey; |
33 | 35 | import tech.pegasys.teku.infrastructure.async.AsyncRunner; |
34 | 36 | import tech.pegasys.teku.infrastructure.async.SafeFuture; |
|
41 | 43 | import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; |
42 | 44 | import tech.pegasys.teku.infrastructure.restapi.RestApi; |
43 | 45 | import tech.pegasys.teku.infrastructure.time.TimeProvider; |
| 46 | +import tech.pegasys.teku.infrastructure.version.VersionProvider; |
44 | 47 | import tech.pegasys.teku.service.serviceutils.Service; |
45 | 48 | import tech.pegasys.teku.service.serviceutils.ServiceConfig; |
46 | 49 | import tech.pegasys.teku.service.serviceutils.layout.DataDirLayout; |
@@ -169,9 +172,18 @@ public static ValidatorClientService create( |
169 | 172 |
|
170 | 173 | final ValidatorLoader validatorLoader = |
171 | 174 | createValidatorLoader(services, config, asyncRunner, updatableGraffitiProvider); |
| 175 | + |
| 176 | + final MetricsSystem metricsSystem = services.getMetricsSystem(); |
| 177 | + |
| 178 | + /* Only available when running a standalone VC client */ |
| 179 | + if (validatorConfig.getSentryNodeConfigurationFile().isPresent() |
| 180 | + || validatorConfig.getBeaconNodeApiEndpoints().isPresent()) { |
| 181 | + addVersionMetric(metricsSystem); |
| 182 | + } |
| 183 | + |
172 | 184 | final ValidatorStatusProvider validatorStatusProvider = |
173 | 185 | new OwnedValidatorStatusProvider( |
174 | | - services.getMetricsSystem(), |
| 186 | + metricsSystem, |
175 | 187 | validatorLoader.getOwnedValidators(), |
176 | 188 | validatorApiChannel, |
177 | 189 | config.getSpec(), |
@@ -234,7 +246,7 @@ public static ValidatorClientService create( |
234 | 246 | beaconProposerPreparer, |
235 | 247 | validatorRegistrator, |
236 | 248 | config.getSpec(), |
237 | | - services.getMetricsSystem(), |
| 249 | + metricsSystem, |
238 | 250 | doppelgangerDetectionAction, |
239 | 251 | maybeValidatorSlashedAction, |
240 | 252 | services.getTimeProvider()); |
@@ -394,7 +406,6 @@ private static BeaconNodeApi createBeaconNodeApi( |
394 | 406 | final SentryNodesConfig sentryNodesConfig = |
395 | 407 | new SentryNodesConfigLoader() |
396 | 408 | .load(validatorConfig.getSentryNodeConfigurationFile().get()); |
397 | | - |
398 | 409 | beaconNodeApi = |
399 | 410 | SentryBeaconNodeApi.create( |
400 | 411 | services, |
@@ -566,6 +577,17 @@ private static void addValidatorCountMetric( |
566 | 577 | validators::getValidatorCount); |
567 | 578 | } |
568 | 579 |
|
| 580 | + private static void addVersionMetric(final MetricsSystem metricsSystem) { |
| 581 | + final String version = VersionProvider.IMPLEMENTATION_VERSION.replaceAll("^v", ""); |
| 582 | + final LabelledMetric<Counter> versionCounter = |
| 583 | + metricsSystem.createLabelledCounter( |
| 584 | + TekuMetricCategory.VALIDATOR, |
| 585 | + VersionProvider.CLIENT_IDENTITY + "_version_total", |
| 586 | + "Teku version in use", |
| 587 | + "version"); |
| 588 | + versionCounter.labels(version).inc(); |
| 589 | + } |
| 590 | + |
569 | 591 | @Override |
570 | 592 | protected SafeFuture<?> doStart() { |
571 | 593 | return initializationComplete |
|
0 commit comments