Skip to content

Commit

Permalink
Renaming some spans and cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Apr 18, 2024
1 parent a56b66a commit ee90c3c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions runner/src/indexer-meta/indexer-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -69,7 +69,7 @@ export default class IndexerMeta {
}

async setStatus (status: IndexerStatus): Promise<void> {
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);

Expand All @@ -81,7 +81,7 @@ export default class IndexerMeta {
}

async updateBlockHeight (blockHeight: number): Promise<void> {
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);

Expand Down
6 changes: 3 additions & 3 deletions runner/src/indexer/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand All @@ -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(':');
Expand Down
2 changes: 0 additions & 2 deletions runner/src/provisioner/provisioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions runner/src/stream-handler/stream-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ee90c3c

Please sign in to comment.