go-chi / go-chi/httplog

high memory usage when using `LogExtraAttrs`

Open
#62 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
319
Forks
45
Avg merge
3d 16h
Merged PRs (30d)
6

Description

When using `LogExtraAttrs` to add additional attributes to the log, the `reqBody` is passed as a string parameter. In the case of large request bodies, for example, file uploads, this can lead to high memory usage.

Additionally, in situations where `reqBody` isn't accessed within `LogExtraAttrs`, there is unnecessary processing overhead introduced with [TeeReader](https://github.com/go-chi/httplog/blob/master/middleware.go#L46).

Possibly adding an alternate callback for adding attributes to the log that doesn't involve the request body, and/or a way to opt-in/out of having access to the `reqBody`?

Would solicit input on the preferred approach to implement, but happy to submit a PR if there is an appetite to address this.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.