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

chore: replace info-level logs with debug #116

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
3 changes: 2 additions & 1 deletion packages/indexer-api/src/database/database.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function connectToDatabase(
) {
try {
const database = await createDataSource(databaseConfig).initialize();
logger.info({
logger.debug({
at: "IndexerAPI#connectToDatabase",
message: "Postgres connection established",
});
Expand All @@ -16,6 +16,7 @@ export async function connectToDatabase(
logger.error({
at: "IndexerAPI#connectToDatabase",
message: "Unable to connect to database",
notificationPath: "across-indexer-error",
error,
});
throw error;
Expand Down
12 changes: 7 additions & 5 deletions packages/indexer-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ async function initializeRedis(

return new Promise<Redis>((resolve, reject) => {
redis.on("ready", () => {
logger.info({
at: "Indexer-API",
logger.debug({
at: "IndexerAPI",
message: "Redis connection established",
config,
});
Expand All @@ -28,8 +28,9 @@ async function initializeRedis(

redis.on("error", (err) => {
logger.error({
at: "Indexer-API",
at: "IndexerAPI",
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to specify what the function is. I.e. IndexerAPI#main

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done here b59aa5c

message: "Redis connection failed",
notificationPath: "across-indexer-error",
error: err,
});
reject(err);
Expand All @@ -42,7 +43,7 @@ export async function connectToDatabase(
) {
try {
const database = await createDataSource(databaseConfig).initialize();
logger.info({
logger.debug({
at: "IndexerAPI#connectToDatabase",
message: "Postgres connection established",
});
Expand All @@ -51,6 +52,7 @@ export async function connectToDatabase(
logger.error({
at: "IndexerAPI#connectToDatabase",
message: "Unable to connect to database",
notificationPath: "across-indexer-error",
error,
});
throw error;
Expand Down Expand Up @@ -102,8 +104,8 @@ export async function Main(
const app = ExpressApp(allRouters);

logger.info({
at: "IndexerAPI#Main",
message: `Starting indexer api on port ${port}`,
at: "main.ts",
});
void (await new Promise((res) => {
app.listen(port, () => res(app));
Expand Down
3 changes: 2 additions & 1 deletion packages/indexer-database/src/utils/BaseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class BaseRepository {
.values(data)
.returning("*")
.execute();
this.logger.info({
this.logger.debug({
at: "BaseRepository#insert",
message: `Saved ${data.length} ${repository.metadata.name} events`,
});
Expand All @@ -30,6 +30,7 @@ export class BaseRepository {
this.logger.error({
at: "BaseRepository#insert",
message: `There was an error while saving ${repository.metadata.name} events`,
notificationPath: "across-indexer-error",
error,
});
if (throwError || this.throwError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
blockRange: BlockRange,
lastFinalisedBlock: number,
) {
this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Start processing block range ${this.getDataIdentifier()}`,
blockRange,
lastFinalisedBlock,
Expand All @@ -64,8 +64,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
let events: FetchEventsResult;

if (this.cachedFetchEventsResult) {
this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Using cached events for ${this.getDataIdentifier()}`,
});
events = this.cachedFetchEventsResult;
Expand All @@ -74,8 +74,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
this.cachedFetchEventsResult = events;
}

this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Fetched events ${this.getDataIdentifier()}`,
events: {
proposedRootBundleEvents: events.proposedRootBundleEvents.length,
Expand All @@ -88,8 +88,8 @@ export class HubPoolIndexerDataHandler implements IndexerDataHandler {
identifier: this.getDataIdentifier(),
});
await this.storeEvents(events, lastFinalisedBlock);
this.logger.info({
at: "HubPoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#HubPoolIndexerDataHandler#processBlockRange",
message: `Finished processing block range ${this.getDataIdentifier()}`,
blockRange,
lastFinalisedBlock,
Expand Down
14 changes: 8 additions & 6 deletions packages/indexer/src/data-indexing/service/Indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export class Indexer {
}

if (!blockRangeResult?.blockRange) {
this.logger.info({
at: "Indexer::start",
this.logger.debug({
at: "Indexer#start",
message: `No new blocks to process ${this.dataHandler.getDataIdentifier()}`,
blockRangeResult,
dataIdentifier: this.dataHandler.getDataIdentifier(),
Expand All @@ -70,8 +70,10 @@ export class Indexer {
blockRangeProcessedSuccessfully = true;
} catch (error) {
this.logger.error({
at: "Indexer::start",
at: "Indexer#start",
message: "Error processing block range",
notificationPath: "across-indexer-error",
blockRangeResult,
dataIdentifier: this.dataHandler.getDataIdentifier(),
error,
});
Expand All @@ -80,8 +82,8 @@ export class Indexer {
if (!blockRangeResult?.isBackfilling) {
await across.utils.delay(this.config.loopWaitTimeSeconds);
} else {
this.logger.info({
at: "Indexer::start",
this.logger.debug({
at: "Indexer#start",
message: `Skip delay ${this.dataHandler.getDataIdentifier()}. Backfill in progress...`,
dataIdentifier: this.dataHandler.getDataIdentifier(),
});
Expand All @@ -96,7 +98,7 @@ export class Indexer {
*/
public stopGracefully() {
this.logger.info({
at: "Indexer::stopGracefully",
at: "Indexer#stopGracefully",
message: `Requesting indexer ${this.dataHandler.getDataIdentifier()} to be stopped`,
});
this.stopRequested = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler {
blockRange: BlockRange,
lastFinalisedBlock: number,
) {
this.logger.info({
at: "SpokePoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#SpokePoolIndexerDataHandler#processBlockRange",
message: `Processing block range ${this.getDataIdentifier()}`,
blockRange,
lastFinalisedBlock,
Expand All @@ -91,8 +91,8 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler {
).reduce((acc, speedUps) => {
return acc + Object.values(speedUps).length;
}, 0);
this.logger.info({
at: "SpokePoolIndexerDataHandler::processBlockRange",
this.logger.debug({
at: "Indexer#SpokePoolIndexerDataHandler#processBlockRange",
message: `Found events for ${this.getDataIdentifier()}`,
events: {
v3FundsDepositedEvents: events.v3FundsDepositedEvents.length,
Expand Down
3 changes: 2 additions & 1 deletion packages/indexer/src/database/database.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function connectToDatabase(
) {
try {
const database = await createDataSource(databaseConfig).initialize();
logger.info({
logger.debug({
at: "Indexer#connectToDatabase",
message: "Postgres connection established",
});
Expand All @@ -16,6 +16,7 @@ export async function connectToDatabase(
logger.error({
at: "Indexer#connectToDatabase",
message: "Unable to connect to database",
notificationPath: "across-indexer-error",
error,
});
throw error;
Expand Down
15 changes: 8 additions & 7 deletions packages/indexer/src/generics/BaseIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export abstract class BaseIndexer {
private readonly name: string,
) {
this.logger.debug({
at: "BaseIndexer#constructor",
at: "Indexer#BaseIndexer#constructor",
message: `Instantiated indexer ${name}`,
});
}
Expand All @@ -25,8 +25,8 @@ export abstract class BaseIndexer {
* @param delay The delay in seconds between each iteration of the indexer
*/
public async start(delay: number): Promise<void> {
this.logger.info({
at: "BaseIndexer#start",
this.logger.debug({
at: "Indexer#BaseIndexer#start",
message: `Starting indexer ${this.name}`,
});

Expand All @@ -35,8 +35,9 @@ export abstract class BaseIndexer {
await this.initialize();
} catch (e) {
this.logger.error({
at: "BaseIndexer#start",
at: "Indexer#BaseIndexer#start",
message: `Failed to initialize ${this.name}`,
notificationPath: "across-indexer-error",
error: (e as unknown as Error).message,
});
return;
Expand All @@ -48,8 +49,8 @@ export abstract class BaseIndexer {
await across.utils.delay(delay);
} while (!this.stopRequested);

this.logger.info({
at: "BaseIndexer#start",
this.logger.debug({
at: "Indexer#BaseIndexer#start",
message: `Ended halted ${this.name}`,
});
}
Expand All @@ -60,7 +61,7 @@ export abstract class BaseIndexer {
*/
public stop(): void {
this.logger.info({
at: "BaseIndexer#stop",
at: "Indexer#BaseIndexer#stop",
message: `Requesting indexer ${this.name} to be stopped`,
});
this.stopRequested = true;
Expand Down
9 changes: 5 additions & 4 deletions packages/indexer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function initializeRedis(

return new Promise<Redis>((resolve, reject) => {
redis.on("ready", () => {
logger.info({
logger.debug({
at: "Indexer#initializeRedis",
message: "Redis connection established",
config,
Expand All @@ -42,6 +42,7 @@ async function initializeRedis(
logger.error({
at: "Indexer#initializeRedis",
message: "Redis connection failed",
notificationPath: "across-indexer-error",
error: err,
});
reject(err);
Expand All @@ -50,7 +51,7 @@ async function initializeRedis(
}

export async function Main(config: parseEnv.Config, logger: winston.Logger) {
const { redisConfig, postgresConfig, hubChainId } = config;
const { redisConfig, postgresConfig } = config;
const redis = await initializeRedis(redisConfig, logger);
const redisCache = new RedisCache(redis);
const postgres = await connectToDatabase(postgresConfig, logger);
Expand Down Expand Up @@ -137,9 +138,9 @@ export async function Main(config: parseEnv.Config, logger: winston.Logger) {
}
});

logger.info({
message: "Running indexers",
logger.debug({
at: "Indexer#Main",
message: "Running indexers",
});
// start all indexers in parallel, will wait for them to complete, but they all loop independently
const [bundleServicesManagerResults, acrossIndexerManagerResult] =
Expand Down
16 changes: 9 additions & 7 deletions packages/indexer/src/services/BundleBuilderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class BundleBuilderService extends BaseIndexer {
// of heap memory errors from needing to aggregate too much historical data
// from all the chains.
if (!(await this.isCloseEnoughToHead(lastExecutedBundle.proposal))) {
this.logger.info({
at: "BundleBuilder#Processor#indexerLogic",
this.logger.debug({
at: "Indexer#BundleBuilderService#indexerLogic",
message: "Last executed bundle is too far from head, skipping",
lastExecutedBundleBlock: lastExecutedBundle.proposal.blockNumber,
});
Expand All @@ -82,8 +82,8 @@ export class BundleBuilderService extends BaseIndexer {
this.handleHubBalanceAggregation(lastExecutedBundle),
]);

this.logger.info({
at: "BundleBuilderService#indexerLogic",
this.logger.debug({
at: "Indexer#BundleBuilderService#indexerLogic",
message: "Bundle builder loop completed",
currentLoopResult: currentLoopResult.status,
proposedLoopResult: proposedLoopResult.status,
Expand Down Expand Up @@ -171,9 +171,10 @@ export class BundleBuilderService extends BaseIndexer {
// Confirm that our current bundle data is not empty
if (!currentBundleData || currentBundleData.length === 0) {
this.logger.error({
at: "BundleBuilder#Processor#handleHubBalanceAggregation",
at: "Indexer#BundleBuilderService#handleHubBalanceAggregation",
message:
"No current bundle data found. Ensure that the current bundle loop has been run.",
notificationPath: "across-indexer-error",
l1Token,
});
return;
Expand Down Expand Up @@ -296,7 +297,7 @@ export class BundleBuilderService extends BaseIndexer {
// If no proposed bundle is found, skip the rest of the logic
if (!utils.isDefined(lastProposedBundle)) {
this.logger.debug({
at: "BundleBuilder#Processor#handleProposedBundleLoop",
at: "Indexer#BundleBuilderService#handleProposedBundleLoop",
message: "No proposed bundles found, skipping.",
});
// Clear the cache so that we don't have any stale data
Expand Down Expand Up @@ -373,8 +374,9 @@ export class BundleBuilderService extends BaseIndexer {
// an ample lookback range
if (!historicalProposal) {
this.logger.error({
at: "BundleBuilder#Processor#callRange",
at: "Indexer#BundleBuilderService#callRange",
message: "No historical proposal found",
notificationPath: "across-indexer-error",
});
throw new Error("No historical proposal found");
}
Expand Down
Loading