Support Server-Timing Specification
#293
Open
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.
This PR introduces a few things, but with a main focus on the
Server-TimingSpecification.The
Server-Timingspecification can allow us much greater and simple insight into the performance and behavior of the backend without having to invest in complicated analytics or greatly increased logging. It lets us at a glance see how long certain tasks take so that we can later attempt to optimize them or identify problems in them.You'll notice to do this I had to make a few other changes:
node.versionEach controller has a standard object schema that allows dynamic ExpressJS route building, dynamic Swagger UI documentation updates, and reduces boilerplate needed for definitions. But the changes in this PR change the positional parameters provided to the main
logicfunction, so instead of updating every single controller like I've done in the past, I opted to instead to define aversionkey on the node which allows us to handle it differently in the dynamic portion of the ExpressJS route builder, meaning we can update bit by bit instead of all at once.New Context Object
Because I also wanted to take this chance to stop having to define new instances of
CallStackand the newTimecopclass, we also have a new context object for v2 Nodes that handles the creation of these common classes automatically. It also bundles thereq,resandparamsobjects into it, which allows us to call thelogicfunction with a single positional parameter.I do want to mention that these new changes will also be the backbone of other cool future plans:
reqobjectNow lets talk about some of the downsides:
Something I fear will need to be done when recreating the contract between a controller and the main app, which has been a problem in this codebase since forever, is we will need to re-write the tests for this. I think this time around our best bet is to rely much more heavily on HTTP based tests, we already do this in some capacity, but realistically since HTTP is our only service contract that should be our priority in tests, while still attempting to test the smaller components when possible.
One last important note, I've only added
Server-Timingfor a single endpoint, since adding it on each endpoint is relatively small I hope to do it while working on other sections of the code, but this PR contains the bulk of the initial setup needed for this to work at all