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

Add more data to Server-Timing header #2983

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

develop7
Copy link
Collaborator

@develop7 develop7 commented Oct 2, 2023

Introduces the performance metrics' collection and rendering in Server-Timing header

fixes #2771

  • metrics
    • query
    • jwt
    • plan
    • render
  • tests
  • CHANGELOG

@develop7 develop7 force-pushed the feature-2771-done-fast branch 2 times, most recently from 4d12745 to 763887b Compare October 5, 2023 12:00
@develop7
Copy link
Collaborator Author

develop7 commented Oct 5, 2023

dead code error at https://github.com/PostgREST/postgrest/actions/runs/6418699702/job/17427023445?pr=2983#step:4:119, the matchHeaderPresent gets unused after my PR; I'd say it's a handy matcher, I'd leave it, but don't know how

@develop7 develop7 marked this pull request as ready for review October 5, 2023 12:22
@steve-chavez
Copy link
Member

@develop7 Interesting! So doing:

# PGRST_DB_PLAN_ENABLED="true" postgrest-with-postgresql-15 postgrest-run

$ curl 'localhost:3000/projects?select=*,clients(*)'  -I
Server-Timing: jwt;dur=16.0, render;dur=8.8, plan;dur=16956.1, query;dur=763.5

$ curl 'localhost:3000/projects?select=*,clients(*)'  -I
Server-Timing: jwt;dur=13.3, render;dur=7.5, plan;dur=118.7, query;dur=1156.1

$ curl 'localhost:3000/projects?select=*,clients(*)'  -I
Server-Timing: jwt;dur=34.3, render;dur=11.9, plan;dur=283.7, query;dur=1121.3

$ curl 'localhost:3000/projects?select=*,clients(*)'  -I
Server-Timing: jwt;dur=15.4, render;dur=5.0, plan;dur=119.0, query;dur=478.7

$ curl 'localhost:3000/projects?select=*,clients(*)'  -I
Server-Timing: jwt;dur=30.4, render;dur=9.8, plan;dur=274.1, query;dur=1165.8

Shows that:

dead code error at https://github.com/PostgREST/postgrest/actions/runs/6418699702/job/17427023445?pr=2983#step:4:119, the matchHeaderPresent gets unused after my PR; I'd say it's a handy matcher, I'd leave it, but don't know how

Yeah, maybe just comment it for now?

src/PostgREST/App.hs Outdated Show resolved Hide resolved
@wolfgangwalther
Copy link
Member

dead code error at https://github.com/PostgREST/postgrest/actions/runs/6418699702/job/17427023445?pr=2983#step:4:119, the matchHeaderPresent gets unused after my PR; I'd say it's a handy matcher, I'd leave it, but don't know how

Yeah, maybe just comment it for now?

Please don't. The dead code checker is there for exactly this reason: To remove dead code. If you comment it out... the code is still dead. The point of removing dead code is to reduce maintenance effort. And commenting out does not help with it.

@develop7
Copy link
Collaborator Author

develop7 commented Oct 6, 2023

Please don't. The dead code checker is there for exactly this reason: To remove dead code. If you comment it out... the code is still dead. The point of removing dead code is to reduce maintenance effort. And commenting out does not help with it.

Good point, although the above matcher still can be handy later, can it? Ideally, it belongs if not hspec-wai itself, then hspec-wai-extra for certain. This SpecHelper module serves as a project-specific lightweight library, rather than stores business logic, so I'm not sure deleting helpers from here would decrease maintenance efforts significantly. On the other hand, the scenario when one day we delete it and next month we need it again, seems quite feasible to me.

@wolfgangwalther
Copy link
Member

Good point, although the above matcher still can be handy later, can it? Ideally, it belongs if not hspec-wai itself, then hspec-wai-extra for certain. This SpecHelper module serves as a project-specific lightweight library, rather than stores business logic, so I'm not sure deleting helpers from here would decrease maintenance efforts significantly. On the other hand, the scenario when one day we delete it and next month we need it again, seems quite feasible to me.

Of course it can be handy later. But nothing stops you from adding it later, again.

The point about maintainability is: You can't make sure to have dead code (commented out code is even worse) to stay in sync with the remaining application - because it's dead. Are you sure the helper will work exactly the same when commenting it in again in a year or two? Maybe yes, maybe no. In this case the chance of a yes might be quite high.. but this is much more general than that: You can never be sure.

And it reduces readability, too. If I have to skip over commented out code everywhere... that's just much harder for me to parse visually.

Commenting out code should be a no-go, once you check for dead code...

@develop7 develop7 force-pushed the feature-2771-done-fast branch from 68ba613 to b575ae2 Compare October 6, 2023 13:46
@develop7
Copy link
Collaborator Author

develop7 commented Oct 6, 2023

@wolfgangwalther agree. Deleted it.

@develop7 develop7 requested a review from steve-chavez October 11, 2023 12:55
@develop7
Copy link
Collaborator Author

I also wonder if we should adopt prometheus support… oh, there's #1526 about that.

Copy link
Member

@steve-chavez steve-chavez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@develop7 Great work! The new modules and test helpers are really clean too 👍.

Don't forget to add an entry to the CHANGELOG!

@develop7 develop7 force-pushed the feature-2771-done-fast branch from 84819b3 to d904291 Compare October 12, 2023 09:16
@develop7
Copy link
Collaborator Author

@steve-chavez changelog done, rebasing done. Hit it!

@develop7 develop7 self-assigned this Oct 12, 2023
@steve-chavez steve-chavez merged commit dc01c74 into PostgREST:main Oct 12, 2023
28 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Server-Timing response header
3 participants