Skip to content
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

apollo-server-core: unified Studio reporting #4142

Merged
merged 46 commits into from Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
295015f
Unified: handoff from Josh to David
May 21, 2020
87c1193
update snapshot
glasser Apr 19, 2021
1da9e6e
Add FIXMEs, fix easy stuff
glasser Apr 19, 2021
7a4a4eb
keep plugin directory prettier
glasser Apr 19, 2021
50ce44d
Filename matches class name
glasser Apr 19, 2021
0c20937
Make traceHasErrors stop the whole walk
glasser Apr 19, 2021
4e931ee
prettier
glasser Apr 19, 2021
0b7df92
build
glasser Apr 19, 2021
c68e2d9
build
glasser Apr 19, 2021
2fe97d0
no |void
glasser Apr 20, 2021
37c201d
comment
glasser Apr 20, 2021
9772dc0
Clean up null fields, aliases, etc
glasser Apr 20, 2021
f33eec4
don't export classes, make them declare Required
glasser Apr 20, 2021
8e7fe19
full review of contextualizedStats.ts, various tweaks
glasser Apr 20, 2021
8258710
no linked list
glasser Apr 20, 2021
d0c6386
set report.endtime
glasser Apr 21, 2021
d5d095c
Update protobuf and improve a few things
glasser Apr 22, 2021
6a9af78
move stuff and rename
glasser Apr 22, 2021
29af5e4
oops
glasser Apr 22, 2021
b51905e
cleanup exports
glasser Apr 22, 2021
b73031f
rename files
glasser Apr 22, 2021
3358310
improve tests, including compiling
glasser Apr 22, 2021
ca7d24c
reorder stats.ts, extract iterateOverTrace.ts
glasser Apr 22, 2021
d9a436c
confirmed a FIXME
glasser Apr 22, 2021
08acc3d
review a comment
glasser Apr 22, 2021
9e3f793
actually write trace.cachePolicy
glasser Apr 22, 2021
c6c4e3e
change TracesSeenMap to experimental_sendOperationAsTrace
glasser Apr 22, 2021
d4b4796
Release
glasser Apr 22, 2021
1efda63
prettier
glasser Apr 22, 2021
fe8678f
update protobuf to not do the '|undefined' thing again
glasser Apr 22, 2021
47226e9
Release
glasser Apr 22, 2021
c75fe68
fix
glasser Apr 22, 2021
3c9b363
Release
glasser Apr 22, 2021
6e19825
roll back packagejson
glasser Apr 22, 2021
0786466
Release
glasser Apr 22, 2021
07a050f
estimate size
glasser Apr 23, 2021
621c7c6
remove pointless public
glasser Apr 23, 2021
41e5153
react to tracesIgnored
glasser Apr 23, 2021
084d809
Release
glasser Apr 23, 2021
b071f8e
a way to validate the algorithm
glasser Apr 27, 2021
fe49054
Release
glasser Apr 27, 2021
c934acc
fix stats context
glasser Apr 27, 2021
f7bde25
snap
glasser Apr 27, 2021
43551fa
Release
glasser Apr 27, 2021
7fb3df0
roll back version bumps
glasser Apr 28, 2021
1e0b875
npm i
glasser Apr 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/apollo-reporting-protobuf/package.json
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"clean": "git clean -fdX -- dist",
"prepare": "npm run clean && mkdir dist && npm run pbjs && npm run pbts && cp src/* dist",
"pbjs": "apollo-pbjs --target static-module --out dist/protobuf.js --wrap commonjs --force-number src/reports.proto",
"pbjs": "apollo-pbjs --target static-module --out dist/protobuf.js --wrap commonjs --force-number --no-from-object src/reports.proto",
"pbts": "apollo-pbts -o dist/protobuf.d.ts dist/protobuf.js",
"update-proto": "curl -sSfo src/reports.proto https://usage-reporting.api.apollographql.com/proto/reports.proto"
},
Expand All @@ -29,6 +29,6 @@
},
"homepage": "https://github.com/apollographql/apollo-server#readme",
"dependencies": {
"@apollo/protobufjs": "^1.0.3"
"@apollo/protobufjs": "1.2.0"
}
}
22 changes: 1 addition & 21 deletions packages/apollo-reporting-protobuf/src/index.js
Expand Up @@ -3,29 +3,9 @@ const protobufJS = require('@apollo/protobufjs/minimal');

// Remove Long support. Our uint64s tend to be small (less
// than 104 days).
// XXX Just remove this in our fork?
// https://github.com/protobufjs/protobuf.js/issues/1253
protobufJS.util.Long = undefined;
protobufJS.configure();

// Override the generated protobuf Traces.encode function so that it will look
// for Traces that are already encoded to Buffer as well as unencoded
// Traces. This amortizes the protobuf encoding time over each generated Trace
// instead of bunching it all up at once at sendReport time. In load tests, this
// change improved p99 end-to-end HTTP response times by a factor of 11 without
// a casually noticeable effect on p50 times. This also makes it easier for us
// to implement maxUncompressedReportSize as we know the encoded size of traces
// as we go.
const originalTracesAndStatsEncode = protobuf.TracesAndStats.encode;
protobuf.TracesAndStats.encode = function(message, originalWriter) {
const writer = originalTracesAndStatsEncode(message, originalWriter);
const encodedTraces = message.encodedTraces;
if (encodedTraces != null && encodedTraces.length) {
for (let i = 0; i < encodedTraces.length; ++i) {
writer.uint32(/* id 1, wireType 2 =*/ 10);
writer.bytes(encodedTraces[i]);
}
}
return writer;
};

module.exports = protobuf;
6 changes: 5 additions & 1 deletion packages/apollo-reporting-protobuf/src/reports.proto
Expand Up @@ -375,6 +375,10 @@ message ContextualizedStats {

// A sequence of traces and stats. An individual trace should either be counted as a stat or trace
message TracesAndStats {
repeated Trace trace = 1;
repeated Trace trace = 1 [(js_preEncoded)=true];
repeated ContextualizedStats stats_with_context = 2 [(js_use_toArray)=true];
// This field is used to validate that the algorithm used to construct `stats_with_context`
// matches similar algorithms in Apollo's servers. It is otherwise ignored and should not
// be included in reports.
repeated Trace internal_traces_contributing_to_stats = 3 [(js_preEncoded)=true];
}
2 changes: 1 addition & 1 deletion packages/apollo-server-core/src/plugin/traceTreeBuilder.ts
Expand Up @@ -261,7 +261,7 @@ function errorToProtobufError(error: GraphQLError): Trace.Error {
}

// Converts a JS Date into a Timestamp.
function dateToProtoTimestamp(date: Date): google.protobuf.Timestamp {
export function dateToProtoTimestamp(date: Date): google.protobuf.Timestamp {
const totalMillis = +date;
const millis = totalMillis % 1000;
return new google.protobuf.Timestamp({
Expand Down