-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Sync Stream Metadata Logs #413
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
12 commits
Select commit
Hold shift + click to select a range
06847c6
add app metadata
stevensJourney 8746f50
Merge remote-tracking branch 'origin/main' into metadata-logs
stevensJourney 1f4ca94
rename variable
stevensJourney f9e6e7f
Improve truncation. Increase limits. Log at sync stream start and end.
stevensJourney a9d6212
remove from websocket general meta
stevensJourney 4e4db6e
cleanup
stevensJourney 5de8c27
remove streams for now
stevensJourney 5556870
changeset typo
stevensJourney d51cd46
Code cleanup
stevensJourney 94ea401
explicit client params in test
stevensJourney 139c380
update logging limits
stevensJourney df088e1
Merge branch 'main' into metadata-logs
stevensJourney 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@powersync/service-core': minor | ||
| --- | ||
|
|
||
| Added ability to specify app_metadata for sync/stream requests |
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,60 @@ | ||
| /** | ||
| * Options for {@link limitParamsForLogging}. | ||
| */ | ||
| export type ParamLoggingFormatOptions = { | ||
| maxKeyCount: number; | ||
| maxStringLength: number; | ||
| }; | ||
|
|
||
| /** | ||
| * Default options for {@link limitParamsForLogging}. | ||
| */ | ||
| export const DEFAULT_PARAM_LOGGING_FORMAT_OPTIONS: ParamLoggingFormatOptions = { | ||
| maxKeyCount: 20, | ||
| maxStringLength: 100 | ||
| }; | ||
|
|
||
| /** | ||
| * Formats potentially arbitrary parameters for logging. | ||
| * This limits the number of keys and strings to a maximum length. | ||
| * A warning key-value is added if the number of keys exceeds the maximum. | ||
| * String values exceeding the maximum length are truncated. | ||
| * Non-String values are stringified, the maximum length is then applied. | ||
| * @param params - The parameters to format. | ||
| * @param options - The options to use. | ||
| * @default DEFAULT_PARAM_LOGGING_FORMAT_OPTIONS | ||
| * @returns The formatted parameters. | ||
| */ | ||
| export function limitParamsForLogging( | ||
| params: Record<string, any>, | ||
| options: Partial<ParamLoggingFormatOptions> = DEFAULT_PARAM_LOGGING_FORMAT_OPTIONS | ||
| ) { | ||
| const { | ||
| maxStringLength = DEFAULT_PARAM_LOGGING_FORMAT_OPTIONS.maxStringLength, | ||
| maxKeyCount = DEFAULT_PARAM_LOGGING_FORMAT_OPTIONS.maxKeyCount | ||
| } = options; | ||
|
|
||
| function trimString(value: string): string { | ||
| if (value.length > maxStringLength) { | ||
| return value.slice(0, maxStringLength - 3) + '...'; | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| return Object.fromEntries( | ||
| Object.entries(params).map(([key, value], index) => { | ||
| if (index == maxKeyCount) { | ||
| return ['⚠️', 'Additional parameters omitted']; | ||
| } | ||
|
|
||
| if (index > maxKeyCount) { | ||
| return []; | ||
| } | ||
|
|
||
| if (typeof value == 'string') { | ||
| return [key, trimString(value)]; | ||
| } | ||
| return [key, trimString(JSON.stringify(value))]; | ||
| }) | ||
| ); | ||
| } |
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
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.