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 request duration to access logs #43

Merged
merged 3 commits into from
Nov 9, 2022

Conversation

haugene
Copy link
Member

@haugene haugene commented Nov 7, 2022

Using Troncos in Salsa and now starting to build new dashboards in Grafana I think this feature would be nice to have.
We get Prometheus metrics on request duration, and we can look at traces/spans that are long. But with metrics we can't backtrack to find a specific slow request and with traces we're combined with Tienda-data so we can't filter at where Salsa was slow.

Adding this would allow us to make dashboards that would light up the slow queries and we could follow the traceID links to drill down into why.

Implementation wise the naming and way of doing this is inspired by two things, the gunicorn logging in Tienda and this asgi logger framework I found.

Open to doing it differently as I don't know the Troncos way of things, but figured I'd just do a quick PR to test it first.
At least it works on my machine 😄 :

logfmt:
time="2022-11-07T11:18:30.760788" level="INFO" logger="salsa.access" http_client_addr="127.0.0.1:57630" http_method="GET" http_path="/api/v1/search/products/" http_version="1.1" http_status_code="200" duration="0.042149"

pretty:
INFO:      127.0.0.1:57118 - GET /api/v1/search/products/ 200 0.018725

Copy link
Contributor

@gbbirkisson gbbirkisson left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@haugene
Copy link
Member Author

haugene commented Nov 9, 2022

Great, so then I'll just merge it and wait for a new release version? 😄

@haugene haugene merged commit a7b1cab into main Nov 9, 2022
@haugene haugene deleted the haugene/add-duration-to-access-logs branch November 9, 2022 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants