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

feat: log http POST requests body in http-access log #3214

Closed
wants to merge 1 commit into from

Conversation

stbrody
Copy link
Contributor

@stbrody stbrody commented Apr 23, 2024

Example log line from the POST request to create a new stream with the genesis commit:

[Tue, 23 Apr 2024 21:11:40 GMT] service=http-access ip=127.0.0.1 ts=2024-04-23T21:11:40.348Z method=POST original_url=/api/v0/streams base_url=/api/v0/streams path=/ params=-  body.type=0 body.genesis={"jws":{"payload":"AXESIDoayVr8HX8osV-ubuCJIrM9d7Xs6bJnmwTXbpO7pTJW","signatures":[{"protected":"eyJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa2oyUVQ4blpvaWF1WGNhMVA0SDZ6d0RqTjlSUDNORFdHazFBWFVkaGgyTjVwI3o2TWtqMlFUOG5ab2lhdVhjYTFQNEg2endEak45UlAzTkRXR2sxQVhVZGhoMk41cCJ9","signature":"78ikyfrUnOHtXXmSkeP6Y0nq9eEmV_Hw-tqNtWWsbIiDIMKdEgrjlZhlewlDjgrkBYTjvqtVSDqgufNA2NiYBA"}],"link":"bafyreib2dlevv7a5p4ulcx5on3qisivthv33l3hjwjtzwbgxn2j3xjjsky"},"linkedBlock":"omRkYXRhoWRzdGVwAGZoZWFkZXKiZnVuaXF1ZXA2VUM3YmxPQ2RWVW1VNUQva2NvbnRyb2xsZXJzgXg4ZGlkOmtleTp6Nk1rajJRVDhuWm9pYXVYY2ExUDRINnp3RGpOOVJQM05EV0drMUFYVWRoaDJONXA"} body.opts={"anchor":true,"publish":true,"sync":0,"syncTimeoutSeconds":0} http_version=1.1 req_header- status=200 content_length=379 content_type="application/json; charset=utf-8" ref=- user_agent="node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" elapsed_ms=82.153 error_message="-" error_code=-

@stbrody stbrody self-assigned this Apr 23, 2024
Copy link

linear bot commented Apr 23, 2024

const valKeys = Object.keys(value)
if (valKeys.length > 0) {
// value is an object
return prev + ` body.${curr}=${JSON.stringify(value)}`
Copy link
Contributor

Choose a reason for hiding this comment

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

is this going to be extremely long? agree we want it tho

Copy link
Contributor Author

@stbrody stbrody Apr 23, 2024

Choose a reason for hiding this comment

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

does seem like a risk, yes. This is printing the full body of the commit being sent to js-ceramic, so is users are creating large json documents in their app, this will print the full document, which could be up to 256kb large

Copy link
Contributor

Choose a reason for hiding this comment

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

um if we do this for every single request on gitcoin i definitely think its a risk of crashing them by filling up the logs. i would like to sample them

Copy link
Contributor

@gvelez17 gvelez17 left a comment

Choose a reason for hiding this comment

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

lgtm, only slightly worried about really long logs. also assuming you tested the morgan.token code

@stbrody
Copy link
Contributor Author

stbrody commented Apr 23, 2024

also assuming you tested the morgan.token code

Not quite sure what you mean by this? The testing I did was running the node, sending http requests to the node, and looking at the log messages generated.

@gvelez17
Copy link
Contributor

also assuming you tested the morgan.token code

Not quite sure what you mean by this? The testing I did was running the node, sending http requests to the node, and looking at the log messages generated.

yeah i meant if there were unit tests, its fine

Are we logging every request? i'm still concerned we could fill up disks with this stuff - hopefully we could log this much detail only on error?

@stbrody
Copy link
Contributor Author

stbrody commented Apr 23, 2024

yeah, agreed this is too verbose right now. We should not merge this without some controls to avoid filling the log with literally every document written to Ceramic.

Copy link
Contributor

@gvelez17 gvelez17 left a comment

Choose a reason for hiding this comment

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

(we agreed that we need to make it a little lighter/more selective before merge)

do you want these maybe? #3215

@stbrody
Copy link
Contributor Author

stbrody commented Jul 19, 2024

This PR needs more work to be ready to merge, and since js-ceramic is dying soon and we've made it this long without this working, going to go ahead and close this unmerged

@stbrody stbrody closed this Jul 19, 2024
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