Skip to content

Commit

Permalink
Determine if metrics are on
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Oct 11, 2023
1 parent dc3b248 commit c629bba
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public BeaconNodeServiceController(
.ifPresent(services::add);
services.add(
ValidatorClientService.create(
serviceConfig, tekuConfig.validatorClient(), new DoppelgangerDetectionShutDown()));
serviceConfig,
tekuConfig.validatorClient(),
tekuConfig.metricsConfig().isMetricsEnabled(),
new DoppelgangerDetectionShutDown()));
}

private Optional<PowchainService> powchainService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public ValidatorNodeServiceController(
final TekuConfiguration tekuConfig, final ServiceConfig serviceConfig) {
this.services.add(
ValidatorClientService.create(
serviceConfig, tekuConfig.validatorClient(), new DoppelgangerDetectionShutDown()));
serviceConfig,
tekuConfig.validatorClient(),
tekuConfig.metricsConfig().isMetricsEnabled(),
new DoppelgangerDetectionShutDown()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class ValidatorClientService extends Service {
private final SafeFuture<Void> initializationComplete = new SafeFuture<>();

private final MetricsSystem metricsSystem;
private final boolean metricsOn;

private ValidatorClientService(
final EventChannels eventChannels,
Expand All @@ -110,6 +111,7 @@ private ValidatorClientService(
final Optional<ValidatorRegistrator> validatorRegistrator,
final Spec spec,
final MetricsSystem metricsSystem,
final boolean metricsOn,
final DoppelgangerDetectionAction doppelgangerDetectionAction) {
this.eventChannels = eventChannels;
this.validatorLoader = validatorLoader;
Expand All @@ -120,12 +122,14 @@ private ValidatorClientService(
this.validatorRegistrator = validatorRegistrator;
this.spec = spec;
this.metricsSystem = metricsSystem;
this.metricsOn = metricsOn;
this.doppelgangerDetectionAction = doppelgangerDetectionAction;
}

public static ValidatorClientService create(
final ServiceConfig services,
final ValidatorClientConfiguration config,
final boolean metricsOn,
final DoppelgangerDetectionAction doppelgangerDetectionAction) {
final EventChannels eventChannels = services.getEventChannels();
final ValidatorConfig validatorConfig = config.getValidatorConfig();
Expand Down Expand Up @@ -199,6 +203,7 @@ public static ValidatorClientService create(
validatorRegistrator,
config.getSpec(),
services.getMetricsSystem(),
metricsOn,
doppelgangerDetectionAction);

asyncRunner
Expand Down Expand Up @@ -410,7 +415,7 @@ private void scheduleValidatorsDuties(
forkProvider,
dependentRoot ->
new SlotBasedScheduledDuties<>(
attestationDutyFactory, dependentRoot, metricsSystem),
attestationDutyFactory, dependentRoot, metricsSystem, metricsOn),
validators,
validatorIndexProvider,
beaconCommitteeSubscriptions,
Expand All @@ -421,7 +426,8 @@ private void scheduleValidatorsDuties(
new BlockProductionDutyLoader(
validatorApiChannel,
dependentRoot ->
new SlotBasedScheduledDuties<>(blockDutyFactory, dependentRoot, metricsSystem),
new SlotBasedScheduledDuties<>(
blockDutyFactory, dependentRoot, metricsSystem, metricsOn),
validators,
validatorIndexProvider));
validatorTimingChannels.add(new BlockDutyScheduler(metricsSystem, blockDutyLoader, spec));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ public class SlotBasedScheduledDuties<P extends Duty, A extends Duty> implements
private final OperationTimer blockProductionDutyTimer;
private final OperationTimer attestationAggregationDutyTimer;

private final boolean metricsOn;

public SlotBasedScheduledDuties(
final DutyFactory<P, A> dutyFactory,
final Bytes32 dependentRoot,
final MetricsSystem metricsSystem) {
final MetricsSystem metricsSystem,
final boolean metricsOn) {
this.dutyFactory = dutyFactory;
this.dependentRoot = dependentRoot;
this.metricsOn = metricsOn;

this.attestationProductionDutyTimer =
metricsSystem.createTimer(
Expand Down Expand Up @@ -115,7 +119,6 @@ private SafeFuture<DutyResult> performDutyForSlot(
return SafeFuture.completedFuture(DutyResult.NO_OP);
}

final boolean metricsOn = true; // todo work out if metrics are turned on
return metricsOn ? performDutyWithMetrics(duty) : duty.performDuty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ private void createDutySchedulerWithRealDuties() {
forkProvider,
dependentRoot ->
new SlotBasedScheduledDuties<>(
attestationDutyFactory, dependentRoot, metricsSystem),
attestationDutyFactory, dependentRoot, metricsSystem, false),
new OwnedValidators(Map.of(VALIDATOR1_KEY, validator1, VALIDATOR2_KEY, validator2)),
validatorIndexProvider,
beaconCommitteeSubscriptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private void createDutySchedulerWithRealDuties() {
validatorApiChannel,
dependentRoot ->
new SlotBasedScheduledDuties<>(
blockDutyFactory, dependentRoot, metricsSystem),
blockDutyFactory, dependentRoot, metricsSystem, false),
new OwnedValidators(
Map.of(VALIDATOR1_KEY, validator1, VALIDATOR2_KEY, validator2)),
validatorIndexProvider)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class SlotBasedScheduledDutiesTest {
private final DutyFactory<ProductionDuty, AggregationDuty> dutyFactory = mock(DutyFactory.class);

private final SlotBasedScheduledDuties<ProductionDuty, AggregationDuty> duties =
new SlotBasedScheduledDuties<>(dutyFactory, Bytes32.fromHexString("0x838382"), metricsSystem);
new SlotBasedScheduledDuties<>(
dutyFactory, Bytes32.fromHexString("0x838382"), metricsSystem, false);

@Test
public void shouldDiscardMissedProductionDuties() {
Expand Down

0 comments on commit c629bba

Please sign in to comment.