-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will allows to find information about received size and total entries per tenant. Example of a log from my dev testing: ``` level=debug ts=2021-01-15T11:16:21.735663076Z caller=http.go:67 org_id=3927 traceID=11c4774c6ec4bbf4 msg="push request parsed" path=/loki/api/v1/push content-type=application/x-protobuf body-size="11 kB" streams=5 entries=298 streamLabelsSize="1.9 kB" entriesSize="45 kB" totalSize="47 kB" ``` Of course this means we can use LogQL on this. Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
- Loading branch information
1 parent
322e4bc
commit 8f87f7b
Showing
2 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package util | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
type sizeReader struct { | ||
size int64 | ||
r io.Reader | ||
} | ||
|
||
type SizeReader interface { | ||
io.Reader | ||
Size() int64 | ||
} | ||
|
||
// NewSizeReader returns an io.Reader that will have the number of bytes | ||
// read from r available. | ||
func NewSizeReader(r io.Reader) SizeReader { | ||
return &sizeReader{r: r} | ||
} | ||
|
||
func (v *sizeReader) Read(p []byte) (int, error) { | ||
n, err := v.r.Read(p) | ||
v.size += int64(n) | ||
return n, err | ||
} | ||
|
||
func (v *sizeReader) Size() int64 { | ||
return v.size | ||
} |