Skip to content

Commit

Permalink
fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiharini committed Sep 16, 2024
1 parent 9f0cdb8 commit cebffb7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/hubble/src/eth/l2EventsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
// Handling: use try-catch + log since errors are expected and not important to surface
try {
if (event.eventName === "Rent") {
statsd().increment("l2events.events_processed", { kind: "storage:rent" });
// Fix when viem fixes https://github.com/wagmi-dev/viem/issues/938
const rentEvent = event as Log<
bigint,
Expand Down Expand Up @@ -379,6 +380,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
// Handling: use try-catch + log since errors are expected and not important to surface
try {
if (event.eventName === "Add") {
statsd().increment("l2events.events_processed", { kind: "key-registry:add" });

Check warning on line 383 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L383

Added line #L383 was not covered by tests
const addEvent = event as Log<
bigint,
number,
Expand Down Expand Up @@ -406,6 +408,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
signerEventBody,
);
} else if (event.eventName === "Remove") {
statsd().increment("l2events.events_processed", { kind: "key-registry:remove" });

Check warning on line 411 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L411

Added line #L411 was not covered by tests
const removeEvent = event as Log<
bigint,
number,
Expand All @@ -430,6 +433,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
signerEventBody,
);
} else if (event.eventName === "AdminReset") {
statsd().increment("l2events.events_processed", { kind: "key-registry:admin-reset" });

Check warning on line 436 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L436

Added line #L436 was not covered by tests
const resetEvent = event as Log<
bigint,
number,
Expand All @@ -454,6 +458,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
signerEventBody,
);
} else if (event.eventName === "Migrated") {
statsd().increment("l2events.events_processed", { kind: "key-registry:migrated" });

Check warning on line 461 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L461

Added line #L461 was not covered by tests
const migratedEvent = event as Log<
bigint,
number,
Expand Down Expand Up @@ -506,6 +511,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
// Handling: use try-catch + log since errors are expected and not important to surface
try {
if (event.eventName === "Register") {
statsd().increment("l2events.events_processed", { kind: "id-registry:register" });

Check warning on line 514 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L514

Added line #L514 was not covered by tests
const registerEvent = event as Log<
bigint,
number,
Expand Down Expand Up @@ -533,6 +539,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
idRegisterEventBody,
);
} else if (event.eventName === "Transfer") {
statsd().increment("l2events.events_processed", { kind: "id-registry:transfer" });

Check warning on line 542 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L542

Added line #L542 was not covered by tests
const transferEvent = event as Log<
bigint,
number,
Expand Down Expand Up @@ -560,6 +567,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
idRegisterEventBody,
);
} else if (event.eventName === "ChangeRecoveryAddress") {
statsd().increment("l2events.events_processed", { kind: "id-registry:change-recovery-address" });

Check warning on line 570 in apps/hubble/src/eth/l2EventsProvider.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/eth/l2EventsProvider.ts#L570

Added line #L570 was not covered by tests
const transferEvent = event as Log<
bigint,
number,
Expand Down Expand Up @@ -928,9 +936,9 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
`syncing events (${formatPercentage((nextFromBlock - fromBlock) / totalBlocks)})`,
);
progressBar?.update(Math.max(nextFromBlock - fromBlock - 1, 0));
statsd().increment("l2events.blocks", Math.min(toBlock, nextToBlock - nextFromBlock));

if (byEventKind) {
// If there are event-specific filters, we don't count the blocks here. The filters mean we don't necessarily consume all the blocks in the provided range. Instead, look at "l2events.events_processed" for an accurate metric.
for (const storageEventSpecific of byEventKind.StorageRegistry) {
await this.getStorageEvents(nextFromBlock, nextToBlock, storageEventSpecific);
}
Expand All @@ -943,6 +951,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
await this.getKeyRegistryEvents(nextFromBlock, nextToBlock, keyRegistryEventSpecific);
}
} else {
statsd().increment("l2events.blocks", Math.min(toBlock, nextToBlock - nextFromBlock));
await this.getStorageEvents(nextFromBlock, nextToBlock);
await this.getIdRegistryEvents(nextFromBlock, nextToBlock);
await this.getKeyRegistryEvents(nextFromBlock, nextToBlock);
Expand Down

0 comments on commit cebffb7

Please sign in to comment.