Skip to content

Commit aeccd08

Browse files
authored
Merge pull request #681 from deniszh/dzhdanov/list_metric_info
Adding info output for /metric/list handler
2 parents ef3b20d + 89dfd40 commit aeccd08

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

carbonserver/list.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ func (listener *CarbonserverListener) listHandler(wr http.ResponseWriter, req *h
8484
var err error
8585

8686
metrics, err := listener.getMetricsList()
87+
accessLogger.Info("list acquired",
88+
zap.Duration("runtime_seconds", time.Since(t0)),
89+
zap.Int("length", len(metrics)),
90+
)
8791
if err != nil {
8892
accessLogger.Error("list failed",
8993
zap.Duration("runtime_seconds", time.Since(t0)),
@@ -109,6 +113,10 @@ func (listener *CarbonserverListener) listHandler(wr http.ResponseWriter, req *h
109113
}
110114
b, err = response.MarshalVT()
111115
}
116+
accessLogger.Info("list formatted",
117+
zap.Duration("runtime_seconds", time.Since(t0)),
118+
zap.Int("length", len(b)),
119+
)
112120

113121
if err != nil {
114122
accessLogger.Error("list failed",
@@ -120,10 +128,11 @@ func (listener *CarbonserverListener) listHandler(wr http.ResponseWriter, req *h
120128
return
121129
}
122130
wr.Header().Set("Content-Type", contentType)
123-
wr.Write(b)
124-
131+
writtenBytes, err := wr.Write(b)
125132
accessLogger.Info("list served",
126133
zap.Duration("runtime_seconds", time.Since(t0)),
134+
zap.Int("write", writtenBytes),
135+
zap.Error(err),
127136
)
128137
}
129138

0 commit comments

Comments
 (0)