Skip to content

Commit cd9a1d5

Browse files
kielbarrykaralabe
authored andcommitted
metrics: golint updates for this or self warning (#16635)
* metrics/*: golint updates for this or self warning * metrics/*: golint updates for this or self warning, updated pr from feedback
1 parent 2ad511c commit cd9a1d5

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

‎metrics/librato/client.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type Batch struct {
6565
Source string `json:"source"`
6666
}
6767

68-
func (self *LibratoClient) PostMetrics(batch Batch) (err error) {
68+
func (c *LibratoClient) PostMetrics(batch Batch) (err error) {
6969
var (
7070
js []byte
7171
req *http.Request
@@ -85,7 +85,7 @@ func (self *LibratoClient) PostMetrics(batch Batch) (err error) {
8585
}
8686

8787
req.Header.Set("Content-Type", "application/json")
88-
req.SetBasicAuth(self.Email, self.Token)
88+
req.SetBasicAuth(c.Email, c.Token)
8989

9090
if resp, err = http.DefaultClient.Do(req); err != nil {
9191
return

‎metrics/librato/librato.go‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ func Librato(r metrics.Registry, d time.Duration, e string, t string, s string,
4040
NewReporter(r, d, e, t, s, p, u).Run()
4141
}
4242

43-
func (self *Reporter) Run() {
43+
func (rep *Reporter) Run() {
4444
log.Printf("WARNING: This client has been DEPRECATED! It has been moved to https://github.com/mihasya/go-metrics-librato and will be removed from rcrowley/go-metrics on August 5th 2015")
45-
ticker := time.Tick(self.Interval)
46-
metricsApi := &LibratoClient{self.Email, self.Token}
45+
ticker := time.Tick(rep.Interval)
46+
metricsApi := &LibratoClient{rep.Email, rep.Token}
4747
for now := range ticker {
4848
var metrics Batch
4949
var err error
50-
if metrics, err = self.BuildRequest(now, self.Registry); err != nil {
50+
if metrics, err = rep.BuildRequest(now, rep.Registry); err != nil {
5151
log.Printf("ERROR constructing librato request body %s", err)
5252
continue
5353
}
@@ -79,21 +79,21 @@ func sumSquaresTimer(t metrics.Timer) float64 {
7979
return sumSquares
8080
}
8181

82-
func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
82+
func (rep *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
8383
snapshot = Batch{
8484
// coerce timestamps to a stepping fn so that they line up in Librato graphs
85-
MeasureTime: (now.Unix() / self.intervalSec) * self.intervalSec,
86-
Source: self.Source,
85+
MeasureTime: (now.Unix() / rep.intervalSec) * rep.intervalSec,
86+
Source: rep.Source,
8787
}
8888
snapshot.Gauges = make([]Measurement, 0)
8989
snapshot.Counters = make([]Measurement, 0)
90-
histogramGaugeCount := 1 + len(self.Percentiles)
90+
histogramGaugeCount := 1 + len(rep.Percentiles)
9191
r.Each(func(name string, metric interface{}) {
92-
if self.Namespace != "" {
93-
name = fmt.Sprintf("%s.%s", self.Namespace, name)
92+
if rep.Namespace != "" {
93+
name = fmt.Sprintf("%s.%s", rep.Namespace, name)
9494
}
9595
measurement := Measurement{}
96-
measurement[Period] = self.Interval.Seconds()
96+
measurement[Period] = rep.Interval.Seconds()
9797
switch m := metric.(type) {
9898
case metrics.Counter:
9999
if m.Count() > 0 {
@@ -125,7 +125,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
125125
measurement[Sum] = float64(s.Sum())
126126
measurement[SumSquares] = sumSquares(s)
127127
gauges[0] = measurement
128-
for i, p := range self.Percentiles {
128+
for i, p := range rep.Percentiles {
129129
gauges[i+1] = Measurement{
130130
Name: fmt.Sprintf("%s.%.2f", measurement[Name], p),
131131
Value: s.Percentile(p),
@@ -142,7 +142,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
142142
Measurement{
143143
Name: fmt.Sprintf("%s.%s", name, "1min"),
144144
Value: m.Rate1(),
145-
Period: int64(self.Interval.Seconds()),
145+
Period: int64(rep.Interval.Seconds()),
146146
Attributes: map[string]interface{}{
147147
DisplayUnitsLong: Operations,
148148
DisplayUnitsShort: OperationsShort,
@@ -152,7 +152,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
152152
Measurement{
153153
Name: fmt.Sprintf("%s.%s", name, "5min"),
154154
Value: m.Rate5(),
155-
Period: int64(self.Interval.Seconds()),
155+
Period: int64(rep.Interval.Seconds()),
156156
Attributes: map[string]interface{}{
157157
DisplayUnitsLong: Operations,
158158
DisplayUnitsShort: OperationsShort,
@@ -162,7 +162,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
162162
Measurement{
163163
Name: fmt.Sprintf("%s.%s", name, "15min"),
164164
Value: m.Rate15(),
165-
Period: int64(self.Interval.Seconds()),
165+
Period: int64(rep.Interval.Seconds()),
166166
Attributes: map[string]interface{}{
167167
DisplayUnitsLong: Operations,
168168
DisplayUnitsShort: OperationsShort,
@@ -184,23 +184,23 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
184184
Max: float64(m.Max()),
185185
Min: float64(m.Min()),
186186
SumSquares: sumSquaresTimer(m),
187-
Period: int64(self.Interval.Seconds()),
188-
Attributes: self.TimerAttributes,
187+
Period: int64(rep.Interval.Seconds()),
188+
Attributes: rep.TimerAttributes,
189189
}
190-
for i, p := range self.Percentiles {
190+
for i, p := range rep.Percentiles {
191191
gauges[i+1] = Measurement{
192192
Name: fmt.Sprintf("%s.timer.%2.0f", name, p*100),
193193
Value: m.Percentile(p),
194-
Period: int64(self.Interval.Seconds()),
195-
Attributes: self.TimerAttributes,
194+
Period: int64(rep.Interval.Seconds()),
195+
Attributes: rep.TimerAttributes,
196196
}
197197
}
198198
snapshot.Gauges = append(snapshot.Gauges, gauges...)
199199
snapshot.Gauges = append(snapshot.Gauges,
200200
Measurement{
201201
Name: fmt.Sprintf("%s.%s", name, "rate.1min"),
202202
Value: m.Rate1(),
203-
Period: int64(self.Interval.Seconds()),
203+
Period: int64(rep.Interval.Seconds()),
204204
Attributes: map[string]interface{}{
205205
DisplayUnitsLong: Operations,
206206
DisplayUnitsShort: OperationsShort,
@@ -210,7 +210,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
210210
Measurement{
211211
Name: fmt.Sprintf("%s.%s", name, "rate.5min"),
212212
Value: m.Rate5(),
213-
Period: int64(self.Interval.Seconds()),
213+
Period: int64(rep.Interval.Seconds()),
214214
Attributes: map[string]interface{}{
215215
DisplayUnitsLong: Operations,
216216
DisplayUnitsShort: OperationsShort,
@@ -220,7 +220,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
220220
Measurement{
221221
Name: fmt.Sprintf("%s.%s", name, "rate.15min"),
222222
Value: m.Rate15(),
223-
Period: int64(self.Interval.Seconds()),
223+
Period: int64(rep.Interval.Seconds()),
224224
Attributes: map[string]interface{}{
225225
DisplayUnitsLong: Operations,
226226
DisplayUnitsShort: OperationsShort,

0 commit comments

Comments
 (0)