Skip to content

Commit

Permalink
Remove unnecessary logs and add Ender metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher-Li committed Aug 21, 2024
1 parent ba3492b commit 2aef590
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
7 changes: 6 additions & 1 deletion indexer/packages/kafka/src/batch-kafka-producer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { logger } from '@dydxprotocol-indexer/base';
import { logger, stats } from '@dydxprotocol-indexer/base';
import { IHeaders, Producer, RecordMetadata } from 'kafkajs';
import _ from 'lodash';

import { KafkaTopics } from './types';
import config from './config';

/**
* Single message sent to the producer.
Expand Down Expand Up @@ -65,6 +66,7 @@ export class BatchKafkaProducer {
}

private sendBatch(): void {
const startTime: number = Date.now();
if (!_.isEmpty(this.producerMessages)) {
this.producerPromises.push(
this.producer.send({ topic: this.topic, messages: this.producerMessages }),
Expand All @@ -80,7 +82,10 @@ export class BatchKafkaProducer {
0,
),
topic: this.topic,
sendTime: Date.now() - startTime,
});
stats.gauge(`${config.SERVICE_NAME}.kafka_batch_size`, this.currentSize);
stats.timing(`${config.SERVICE_NAME}.kafka_batch_send_time`, Date.now() - startTime);
this.producerMessages = [];
this.currentSize = 0;
}
Expand Down
8 changes: 0 additions & 8 deletions indexer/services/ender/src/lib/batched-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ export class BatchedHandlers {
_.forEach(consolidatedKafkaEventGroup, (events: ConsolidatedKafkaEvent[]) => {
kafkaPublisher.addEvents(events);
});
logger.info({
at: 'BatchedHandlers#process',
message: 'Finished processing batch of handlers',
batchIndex,
handlerCountMapping,
batchProcessTime: Date.now() - start,
batchSize: this.batchedHandlers[batchIndex].length,
});
stats.timing(`${config.SERVICE_NAME}.batch_process_time`, Date.now() - start);
stats.histogram(`${config.SERVICE_NAME}.batch_size`, this.batchedHandlers[batchIndex].length);
}
Expand Down
8 changes: 8 additions & 0 deletions indexer/services/ender/src/lib/on-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export async function onMessage(message: KafkaMessage): Promise<void> {
topic: KafkaTopics.TO_ENDER,
},
);
logger.info({
at: 'onMessage#onMessage',
message: 'Processing message',
offset,
blockHeight,
messageTimeInQueue: start - Number(message.timestamp),
numEvents: indexerTendermintBlock.events.length,
});

let success: boolean = false;
const txId: number = await Transaction.start();
Expand Down
6 changes: 0 additions & 6 deletions indexer/services/ender/src/lib/sync-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ export class SyncHandlers {
_.forEach(consolidatedKafkaEventGroup, (events: ConsolidatedKafkaEvent[]) => {
kafkaPublisher.addEvents(events);
});
logger.info({
at: 'SyncHandlers#process',
message: 'Finished processing synchronous handlers',
handlerCountMapping,
batchProcessTime: Date.now() - start,
});
stats.timing(`${config.SERVICE_NAME}.synchronous_events_process_time`, Date.now() - start);
}
}

0 comments on commit 2aef590

Please sign in to comment.