-
Notifications
You must be signed in to change notification settings - Fork 2k
Always send large traces as stats #6897
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
glasser
merged 9 commits into
apollographql:version-4
from
bonnici:nickmarsh/i1291/cap-trace-size
Sep 30, 2022
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
77b27ec
Send large traces as stats
bonnici 806a04e
Added changeset
bonnici 0a6b37a
Prettier
bonnici 6cc897e
Updates from PR comments
bonnici 894e96e
Prettier
bonnici 8d85160
Merge branch 'version-4' into nickmarsh/i1291/cap-trace-size
bonnici aece523
Update wording and remove unnecessary test
bonnici fe9d491
Update packages/server/src/plugin/usageReporting/stats.ts
glasser a6bae36
Apply suggestions from code review
glasser 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 @@ | ||
| --- | ||
| '@apollo/server': patch | ||
| --- | ||
|
|
||
| Send large traces as stats | ||
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 |
|---|---|---|
|
|
@@ -61,20 +61,30 @@ export class OurReport implements Required<IReport> { | |
| trace, | ||
| asTrace, | ||
| referencedFieldsByType, | ||
| // The max size a trace can be before it is sent as stats. Note that the | ||
bonnici marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Apollo reporting ingress server will never store any traces over 10mb | ||
| // anyway. They will instead be converted to stats as we would do here. | ||
|
||
| maxTraceBytes = 10 * 1024 * 1024, | ||
| }: { | ||
| statsReportKey: string; | ||
| trace: Trace; | ||
| asTrace: boolean; | ||
| referencedFieldsByType: ReferencedFieldsByType; | ||
| maxTraceBytes?: number; | ||
| }) { | ||
| const tracesAndStats = this.getTracesAndStats({ | ||
| statsReportKey, | ||
| referencedFieldsByType, | ||
| }); | ||
| if (asTrace) { | ||
| const encodedTrace = Trace.encode(trace).finish(); | ||
| tracesAndStats.trace.push(encodedTrace); | ||
| this.sizeEstimator.bytes += 2 + encodedTrace.length; | ||
|
|
||
| if (!isNaN(maxTraceBytes) && encodedTrace.length > maxTraceBytes) { | ||
| tracesAndStats.statsWithContext.addTrace(trace, this.sizeEstimator); | ||
| } else { | ||
| tracesAndStats.trace.push(encodedTrace); | ||
| this.sizeEstimator.bytes += 2 + encodedTrace.length; | ||
| } | ||
| } else { | ||
| tracesAndStats.statsWithContext.addTrace(trace, this.sizeEstimator); | ||
| } | ||
|
|
||
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.