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

Reduce useless logs #495

Merged
merged 3 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion carbonserver/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (listener *CarbonserverListener) renderHandler(wr http.ResponseWriter, req
zap.Strings("targets", tgs),
)

logger := TraceContextToZap(ctx, listener.accessLogger.With(
logger := TraceContextToZap(ctx, listener.logger.With(
zap.String("handler", "render"),
zap.String("url", req.URL.RequestURI()),
zap.String("peer", req.RemoteAddr),
Expand Down
22 changes: 22 additions & 0 deletions persister/whisper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package persister

import (
"errors"
"fmt"
"io/fs"
"log"
Expand All @@ -22,6 +23,8 @@ import (
)

const storeMutexCount = 32768
const maxPathLength = 4095
const maxFilenameLength = 255

type StoreFunc func(metric string)

Expand Down Expand Up @@ -255,6 +258,25 @@ func (p *Whisper) store(metric string) {
path = filepath.Join(p.rootPath, strings.ReplaceAll(metric, ".", "/")+".wsp")
}

if len(path) > maxPathLength {
p.logger.Debug("metric name exceeds limit",
zap.String("path", path),
zap.Error(errors.New("path too long")))
p.popConfirm(metric)
return
}
filenames := strings.Split(path, "/")
for _, filename := range filenames {
if len(filename) > maxFilenameLength {
p.logger.Debug("metric name exceeds limit",
zap.String("path", path),
zap.String("filename", filename),
zap.Error(errors.New("filename too long")))
p.popConfirm(metric)
return
}
}

var newFile bool
w, err := whisper.OpenWithOptions(path, &whisper.Options{
FLock: p.flock,
Expand Down
2 changes: 1 addition & 1 deletion receiver/tcp/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (rcv *TCP) HandleConnection(conn net.Conn) {
name, value, timestamp, err := parse.PlainLine(line)
if err != nil {
atomic.AddUint32(&rcv.errors, 1)
rcv.logger.Info("parse failed",
rcv.logger.Debug("parse failed",
zap.Error(err),
zap.String("peer", conn.RemoteAddr().String()),
)
Expand Down
2 changes: 1 addition & 1 deletion receiver/udp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (rcv *UDP) receiveWorker(exit chan bool) {
name, value, timestamp, err := parse.PlainLine(line)
if err != nil {
atomic.AddUint32(&rcv.errors, 1)
rcv.logger.Info("parse failed",
rcv.logger.Debug("parse failed",
zap.Error(err),
zap.String("peer", peer.String()),
)
Expand Down