Skip to content

Improve logging in a few places so more context is shared with logs such as chainId - #90

Merged
JasoonS merged 3 commits into
mainfrom
fix/improved-logging
Jul 26, 2024
Merged

Improve logging in a few places so more context is shared with logs such as chainId#90
JasoonS merged 3 commits into
mainfrom
fix/improved-logging

Conversation

@JasoonS

@JasoonS JasoonS commented Jul 26, 2024

Copy link
Copy Markdown
Contributor

No description provided.

let blockNumbersAndHashes = await getBlockHashes(~blockNumbers)->Promise.thenResolve(res =>
let blockNumbersAndHashes = await getBlockHashes(
~blockNumbers,
~logger=chainFetcher.logger,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We now pass this through in many places to keep the context

Comment on lines +634 to +640
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,
},

@JasoonS JasoonS Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is is an important change, now I pass in the "chainId"


let getBlockHashes = (~blockNumbers) => {
let getBlockHashes = (~blockNumbers, ~logger) => {
let _currentlyUnusedLogger = logger

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should add logging for RPC worker at some point also.

Comment on lines +94 to +97
let currentBlockInterval =
blockIntervals
->Js.Dict.get(partitionId->Belt.Int.toString)
->Belt.Option.getWithDefault(T.rpcConfig.syncConfig.initialBlockInterval)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

formatting - no change

Comment on lines +160 to +163
blockIntervals->Js.Dict.set(
partitionId->Belt.Int.toString,
Pervasives.min(finalExecutedBlockInterval + sc.accelerationAdditive, sc.intervalCeiling),
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

formatting - no change


let logger = Logging.createChild(
let logger = Logging.createChildFrom(
~logger,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Important change, we should make logger that is a child of our main logger.

@JasoonS
JasoonS force-pushed the fix/improved-logging branch from 8d49471 to 8f05150 Compare July 26, 2024 14:32
~params={"type": "hypersync get blockhash query", "blockNumber": blockNumber},
let logger = Logging.createChildFrom(
~logger,
~params={"logType": "hypersync get blockhash query", "blockNumber": blockNumber},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed 'type' to 'logType' for consistency with other logs.

@JasoonS
JasoonS force-pushed the fix/improved-logging branch from 8f05150 to 9ac50fd Compare July 26, 2024 14:38
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.`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added more detail to log message.

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks a little bit messy with dragging the logger through so many places, but in general looks good 👍

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lovely 🫶

@JonoPrest

Copy link
Copy Markdown
Collaborator

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
JasoonS merged commit 7481607 into main Jul 26, 2024
@DZakh

DZakh commented Jul 26, 2024

Copy link
Copy Markdown
Member

@JasoonS You merged it with a failing test again 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants