Skip to content

Commit

Permalink
indexer-agent,indexer-common: Logging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fordN committed Aug 18, 2022
1 parent 5b7bd4a commit 43757da
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
42 changes: 28 additions & 14 deletions packages/indexer-agent/src/agent.ts
Expand Up @@ -173,8 +173,8 @@ class Agent {
const currentEpoch = timer(600_000).tryMap(
() => this.network.contracts.epochManager.currentEpoch(),
{
onError: err =>
this.logger.warn(`Failed to fetch current epoch`, { err }),
onError: error =>
this.logger.warn(`Failed to fetch current epoch`, { error }),
},
)

Expand All @@ -191,26 +191,26 @@ class Agent {
}
},
{
onError: err =>
onError: error =>
this.logger.warn(`Failed to fetch start block of current epoch`, {
err,
error,
}),
},
)

const channelDisputeEpochs = timer(600_000).tryMap(
() => this.network.contracts.staking.channelDisputeEpochs(),
{
onError: err =>
this.logger.warn(`Failed to fetch channel dispute epochs`, { err }),
onError: error =>
this.logger.warn(`Failed to fetch channel dispute epochs`, { error }),
},
)

const maxAllocationEpochs = timer(600_000).tryMap(
() => this.network.contracts.staking.maxAllocationEpochs(),
{
onError: err =>
this.logger.warn(`Failed to fetch max allocation epochs`, { err }),
onError: error =>
this.logger.warn(`Failed to fetch max allocation epochs`, { error }),
},
)

Expand Down Expand Up @@ -250,19 +250,25 @@ class Agent {
const activeDeployments = timer(60_000).tryMap(
() => this.indexer.subgraphDeployments(),
{
onError: () =>
onError: error =>
this.logger.warn(
`Failed to obtain active deployments, trying again later`,
{
error,
},
),
},
)

const networkDeployments = timer(240_000).tryMap(
async () => await this.networkMonitor.subgraphDeployments(),
{
onError: () =>
onError: error =>
this.logger.warn(
`Failed to obtain network deployments, trying again later`,
{
error,
},
),
},
)
Expand All @@ -279,9 +285,12 @@ class Agent {
: evaluateDeployments(this.logger, networkDeployments, indexingRules)
},
{
onError: () =>
onError: error =>
this.logger.warn(
`Failed to obtain target allocations, trying again later`,
{
error,
},
),
},
)
Expand Down Expand Up @@ -314,9 +323,12 @@ class Agent {
: [...targetDeploymentIDs, ...this.offchainSubgraphs]
},
{
onError: () =>
onError: error =>
this.logger.warn(
`Failed to obtain target deployments, trying again later`,
{
error,
},
),
},
)
Expand Down Expand Up @@ -664,7 +676,9 @@ class Agent {
this.logger.warn(
`The following deployments do not have defined cost models and will use the global cost model if it exists`,
{
deployments: deploymentMissingModels,
deployments: deploymentMissingModels.map(
deployment => deployment.ipfsHash,
),
},
)
}
Expand Down Expand Up @@ -704,7 +718,7 @@ class Agent {
deploymentIDSet(activeDeployments) != deploymentIDSet(targetDeployments)
) {
// Turning to trace until the above conditional is fixed
this.logger.trace('Reconcile deployments', {
this.logger.debug('Reconcile deployments', {
syncing: activeDeployments.map(id => id.display),
target: targetDeployments.map(id => id.display),
withActiveOrRecentlyClosedAllocation: eligibleAllocationDeployments.map(
Expand Down
14 changes: 7 additions & 7 deletions packages/indexer-agent/src/indexer.ts
Expand Up @@ -197,7 +197,7 @@ export class Indexer {
},
)

this.logger.info(`Queried index nodes`, {
this.logger.trace(`Queried index nodes`, {
indexNodes,
})
return indexNodes
Expand Down Expand Up @@ -731,14 +731,14 @@ export class Indexer {
activeDeploymentAllocations
.filter(allocation => allocation.createdAtEpoch < epoch)
.map(allocation => allocation.id)
logger.info(
`Deployment is not (or no longer) worth allocating towards, close allocation if it is from a previous epoch`,
{
eligibleForClose: activeDeploymentAllocationsEligibleForClose,
},
)
// Make sure to close all active allocations on the way out
if (activeDeploymentAllocationsEligibleForClose.length > 0) {
logger.info(
`Deployment is not (or no longer) worth allocating towards, close allocation`,
{
eligibleForClose: activeDeploymentAllocationsEligibleForClose,
},
)
await pMap(
// We can only close allocations from a previous epoch;
// try the others again later
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-common/src/indexer-management/monitor.ts
Expand Up @@ -543,7 +543,7 @@ export class NetworkMonitor {
}
}

this.logger.trace(`Fetched subgraph deployments published to network`, {
this.logger.debug(`Finished fetching subgraph deployments published to network`, {
publishedSubgraphs: queryProgress.fetched,
})
return deployments
Expand Down
Expand Up @@ -41,6 +41,7 @@ async function executeQueueOperation(
duplicateAction[0].source === action.source &&
duplicateAction[0].status === action.status
) {
// TODO: Log this only when update will actually change existing item
logger.info(
`Action found in queue that effects the same deployment as proposed queue action, updating existing action`,
{
Expand Down

0 comments on commit 43757da

Please sign in to comment.