Improve logging in a few places so more context is shared with logs such as chainId - #90
Conversation
| let blockNumbersAndHashes = await getBlockHashes(~blockNumbers)->Promise.thenResolve(res => | ||
| let blockNumbersAndHashes = await getBlockHashes( | ||
| ~blockNumbers, | ||
| ~logger=chainFetcher.logger, |
There was a problem hiding this comment.
We now pass this through in many places to keep the context
| let logger = Logging.createChildFrom( | ||
| ~logger, | ||
| ~params={"logType": "Block Range Query", "workerType": ChainWorker.name}, | ||
| ~params={ | ||
| "chainId": chain->ChainMap.Chain.toChainId, | ||
| "logType": "Block Range Query", | ||
| "workerType": ChainWorker.name, | ||
| }, |
There was a problem hiding this comment.
This is is an important change, now I pass in the "chainId"
|
|
||
| let getBlockHashes = (~blockNumbers) => { | ||
| let getBlockHashes = (~blockNumbers, ~logger) => { | ||
| let _currentlyUnusedLogger = logger |
There was a problem hiding this comment.
We should add logging for RPC worker at some point also.
| let currentBlockInterval = | ||
| blockIntervals | ||
| ->Js.Dict.get(partitionId->Belt.Int.toString) | ||
| ->Belt.Option.getWithDefault(T.rpcConfig.syncConfig.initialBlockInterval) |
There was a problem hiding this comment.
formatting - no change
| blockIntervals->Js.Dict.set( | ||
| partitionId->Belt.Int.toString, | ||
| Pervasives.min(finalExecutedBlockInterval + sc.accelerationAdditive, sc.intervalCeiling), | ||
| ) |
There was a problem hiding this comment.
formatting - no change
|
|
||
| let logger = Logging.createChild( | ||
| let logger = Logging.createChildFrom( | ||
| ~logger, |
There was a problem hiding this comment.
Important change, we should make logger that is a child of our main logger.
8d49471 to
8f05150
Compare
| ~params={"type": "hypersync get blockhash query", "blockNumber": blockNumber}, | ||
| let logger = Logging.createChildFrom( | ||
| ~logger, | ||
| ~params={"logType": "hypersync get blockhash query", "blockNumber": blockNumber}, |
There was a problem hiding this comment.
Changed 'type' to 'logType' for consistency with other logs.
8f05150 to
9ac50fd
Compare
| let logger = Logging.createChild(~params={"url": serverUrl}) | ||
| logger->Logging.childWarn( | ||
| `Block #${blockNumber->Belt.Int.toString} not found in hypersync. Retrying query in 100ms.`, | ||
| `Block #${blockNumber->Belt.Int.toString} not found in hypersync. HyperSync runs multiple instances of hypersync and it is possible that they drift independently slightly from the head. Retrying query in 100ms.` |
There was a problem hiding this comment.
Added more detail to log message.
DZakh
left a comment
There was a problem hiding this comment.
Looks a little bit messy with dragging the logger through so many places, but in general looks good 👍
It is a little messy but the logger is where pass the context at the moment for logs. Kind of like anyhow with rust. |
…hainWorkers/RpcWorker.res Co-authored-by: Dmitry Zakharov <dzakh.dev@gmail.com>
|
@JasoonS You merged it with a failing test again 🙈 |
No description provided.