From ee90c3ca48498cb51c11936ce99b3e74976b023b Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 18 Apr 2024 12:17:45 -0700 Subject: [PATCH] Renaming some spans and cleaning up --- runner/src/indexer-meta/indexer-meta.ts | 6 +++--- runner/src/indexer/indexer.ts | 6 +++--- runner/src/provisioner/provisioner.ts | 2 -- runner/src/stream-handler/stream-handler.ts | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/runner/src/indexer-meta/indexer-meta.ts b/runner/src/indexer-meta/indexer-meta.ts index dac39e4a1..b8afcc717 100644 --- a/runner/src/indexer-meta/indexer-meta.ts +++ b/runner/src/indexer-meta/indexer-meta.ts @@ -47,7 +47,7 @@ export default class IndexerMeta { const entriesArray = logEntries.filter(entry => this.shouldLog(entry.level)); if (entriesArray.length === 0) return; - const spanMessage = `write log for ${entriesArray.length === 1 ? 'single entry' : `batch of ${entriesArray.length}`} through postgres `; + const spanMessage = `write batch of ${entriesArray.length} logs through postgres`; const writeLogSpan = this.tracer.startSpan(spanMessage); await wrapError(async () => { @@ -69,7 +69,7 @@ export default class IndexerMeta { } async setStatus (status: IndexerStatus): Promise { - const setStatusSpan = this.tracer.startSpan(`set status of indexer to ${status} through postgres`); + const setStatusSpan = this.tracer.startSpan(`set status to ${status} through postgres`); const values = [[MetadataFields.STATUS, status]]; const setStatusQuery = format(METADATA_TABLE_UPSERT, this.indexerConfig.schemaName(), values); @@ -81,7 +81,7 @@ export default class IndexerMeta { } async updateBlockHeight (blockHeight: number): Promise { - const setLastProcessedBlockSpan = this.tracer.startSpan(`set last processed block to ${blockHeight} through postgres`); + const setLastProcessedBlockSpan = this.tracer.startSpan('set last processed block through postgres'); const values = [[MetadataFields.LAST_PROCESSED_BLOCK_HEIGHT, blockHeight.toString()]]; const updateBlockHeightQuery = format(METADATA_TABLE_UPSERT, this.indexerConfig.schemaName(), values); diff --git a/runner/src/indexer/indexer.ts b/runner/src/indexer/indexer.ts index b3d428145..b1a79b06b 100644 --- a/runner/src/indexer/indexer.ts +++ b/runner/src/indexer/indexer.ts @@ -407,7 +407,7 @@ export default class Indexer { status } }`; - const setStatusSpan = this.tracer.startSpan(`set status of indexer to ${status} through hasura`); + const setStatusSpan = this.tracer.startSpan(`set status to ${status} through hasura`); try { await this.runGraphQLQuery( setStatusMutation, @@ -477,7 +477,7 @@ export default class Indexer { function_name: this.indexerConfig.fullName(), block_height: blockHeight, }; - const setBlockHeightSpan = this.tracer.startSpan('set last processed block height through Hasura'); + const setBlockHeightSpan = this.tracer.startSpan('set last processed block through Hasura'); try { await this.runGraphQLQuery(realTimeMutation, variables, blockHeight, this.DEFAULT_HASURA_ROLE) .catch((e: any) => { @@ -500,7 +500,7 @@ export default class Indexer { insert_indexer_log_entries_one(object: {function_name: $function_name, block_height: $block_height, message: $message}) {id} }`; - const writeLogSpan = this.tracer.startSpan('Write log to log table through Hasura'); + const writeLogSpan = this.tracer.startSpan('Write log through Hasura'); const parsedMessage: string = message .map(m => typeof m === 'object' ? JSON.stringify(m) : m) .join(':'); diff --git a/runner/src/provisioner/provisioner.ts b/runner/src/provisioner/provisioner.ts index 3c5af426f..96eedf096 100644 --- a/runner/src/provisioner/provisioner.ts +++ b/runner/src/provisioner/provisioner.ts @@ -264,12 +264,10 @@ export default class Provisioner { if (!tableNames.includes(logsTable)) { await this.setupPartitionedLogsTable(indexerConfig.userName(), indexerConfig.databaseName(), indexerConfig.schemaName()); - tableNames.push(logsTable); } if (!tableNames.includes(metadataTable)) { await this.createMetadataTable(indexerConfig.databaseName(), indexerConfig.schemaName()); await this.setProvisioningStatus(indexerConfig.userName(), indexerConfig.schemaName()); - tableNames.push(metadataTable); } }, 'Failed logs and metadata provisioning' diff --git a/runner/src/stream-handler/stream-handler.ts b/runner/src/stream-handler/stream-handler.ts index 441cd2c73..438d02e36 100644 --- a/runner/src/stream-handler/stream-handler.ts +++ b/runner/src/stream-handler/stream-handler.ts @@ -61,10 +61,10 @@ export default class StreamHandler { const indexer = new Indexer(this.indexerConfig); indexer.setStatus(0, IndexerStatus.STOPPED).catch((e) => { - console.error(`Failed to set status STOPPED for stream: ${this.indexerConfig.redisStreamKey}`, e); + console.error(`Failed to set status STOPPED for indexer through hasura: ${this.indexerConfig.redisStreamKey}`, e); }); indexer.setStoppedStatus().catch((e) => { - console.error(`Failed to set stopped status for stream in Metadata table: ${this.indexerConfig.redisStreamKey}`, e); + console.error(`Failed to set stopped status for indexer: ${this.indexerConfig.redisStreamKey}`, e); }); const streamErrorLogEntry = LogEntry.systemError(`Encountered error processing stream: ${this.indexerConfig.redisStreamKey}, terminating thread\n${error.toString()}`, this.executorContext.block_height);