-
Notifications
You must be signed in to change notification settings - Fork 3
Improve logging on backend #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d2518f2
Add rampId to logs that are part of a phase handler execution
ebma 3ce950d
Also use rampId log context in recovery and cleanup worker
ebma 52241ab
Fix custom format not applied on console
ebma 71aa10b
Remove timestamp from console logger
ebma 82fe718
Initial plan
Copilot 1ac8e70
Address review comments: remove nested context and fix logger spacing
Copilot c6f99ab
Merge pull request #1016 from pendulum-chain/copilot/sub-pr-1015
ebma a690585
Improve handling of pendulum-to-moonbeam xcm phase
ebma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { AsyncLocalStorage } from "async_hooks"; | ||
|
|
||
| /** | ||
| * Context that is available during ramp processing. | ||
| * This can be extended with additional fields as needed. | ||
| */ | ||
| interface RampProcessingContext { | ||
| rampId: string; | ||
| } | ||
|
|
||
| /** | ||
| * AsyncLocalStorage instance for storing ramp processing context. | ||
| * This allows us to automatically propagate the rampId through async call chains | ||
| * without explicitly passing it as a parameter. | ||
| */ | ||
| const rampContextStorage = new AsyncLocalStorage<RampProcessingContext>(); | ||
|
|
||
| /** | ||
| * Run a function within a ramp context. | ||
| * All async operations within the callback will have access to the rampId. | ||
| * | ||
| * @param rampId The ID of the ramp being processed | ||
| * @param fn The async function to run within the context | ||
| * @returns The result of the async function | ||
| */ | ||
| export function runWithRampContext<T>(rampId: string, fn: () => Promise<T>): Promise<T> { | ||
| return rampContextStorage.run({ rampId }, fn); | ||
| } | ||
|
|
||
| /** | ||
| * Get the current ramp ID from the AsyncLocalStorage context. | ||
| * Returns undefined if not running within a ramp context. | ||
| * | ||
| * @returns The current ramp ID or undefined | ||
| */ | ||
| export function getRampId(): string | undefined { | ||
| return rampContextStorage.getStore()?.rampId; | ||
| } | ||
|
|
||
| /** | ||
| * Get the full ramp context from AsyncLocalStorage. | ||
| * Returns undefined if not running within a ramp context. | ||
| * | ||
| * @returns The current ramp context or undefined | ||
| */ | ||
| export function getRampContext(): RampProcessingContext | undefined { | ||
| return rampContextStorage.getStore(); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.