-
Notifications
You must be signed in to change notification settings - Fork 20.3k
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
metrics/*: golint updates for this or self warning #16635
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -40,14 +40,14 @@ func Librato(r metrics.Registry, d time.Duration, e string, t string, s string, | |
NewReporter(r, d, e, t, s, p, u).Run() | ||
} | ||
|
||
func (self *Reporter) Run() { | ||
func (rep *Reporter) Run() { | ||
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") | ||
ticker := time.Tick(self.Interval) | ||
metricsApi := &LibratoClient{self.Email, self.Token} | ||
ticker := time.Tick(rep.Interval) | ||
metricsApi := &LibratoClient{rep.Email, rep.Token} | ||
for now := range ticker { | ||
var metrics Batch | ||
var err error | ||
if metrics, err = self.BuildRequest(now, self.Registry); err != nil { | ||
if metrics, err = rep.BuildRequest(now, rep.Registry); err != nil { | ||
log.Printf("ERROR constructing librato request body %s", err) | ||
continue | ||
} | ||
|
@@ -79,21 +79,21 @@ func sumSquaresTimer(t metrics.Timer) float64 { | |
return sumSquares | ||
} | ||
|
||
func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) { | ||
func (rep *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) { | ||
snapshot = Batch{ | ||
// coerce timestamps to a stepping fn so that they line up in Librato graphs | ||
MeasureTime: (now.Unix() / self.intervalSec) * self.intervalSec, | ||
Source: self.Source, | ||
MeasureTime: (now.Unix() / rep.intervalSec) * rep.intervalSec, | ||
Source: rep.Source, | ||
} | ||
snapshot.Gauges = make([]Measurement, 0) | ||
snapshot.Counters = make([]Measurement, 0) | ||
histogramGaugeCount := 1 + len(self.Percentiles) | ||
histogramGaugeCount := 1 + len(rep.Percentiles) | ||
r.Each(func(name string, metric interface{}) { | ||
if self.Namespace != "" { | ||
name = fmt.Sprintf("%s.%s", self.Namespace, name) | ||
if rep.Namespace != "" { | ||
name = fmt.Sprintf("%s.%s", rep.Namespace, name) | ||
} | ||
measurement := Measurement{} | ||
measurement[Period] = self.Interval.Seconds() | ||
measurement[Period] = rep.Interval.Seconds() | ||
switch m := metric.(type) { | ||
case metrics.Counter: | ||
if m.Count() > 0 { | ||
|
@@ -125,7 +125,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
measurement[Sum] = float64(s.Sum()) | ||
measurement[SumSquares] = sumSquares(s) | ||
gauges[0] = measurement | ||
for i, p := range self.Percentiles { | ||
for i, p := range rep.Percentiles { | ||
gauges[i+1] = Measurement{ | ||
Name: fmt.Sprintf("%s.%.2f", measurement[Name], p), | ||
Value: s.Percentile(p), | ||
|
@@ -142,7 +142,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
Measurement{ | ||
Name: fmt.Sprintf("%s.%s", name, "1min"), | ||
Value: m.Rate1(), | ||
Period: int64(self.Interval.Seconds()), | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: map[string]interface{}{ | ||
DisplayUnitsLong: Operations, | ||
DisplayUnitsShort: OperationsShort, | ||
|
@@ -152,7 +152,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
Measurement{ | ||
Name: fmt.Sprintf("%s.%s", name, "5min"), | ||
Value: m.Rate5(), | ||
Period: int64(self.Interval.Seconds()), | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: map[string]interface{}{ | ||
DisplayUnitsLong: Operations, | ||
DisplayUnitsShort: OperationsShort, | ||
|
@@ -162,7 +162,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
Measurement{ | ||
Name: fmt.Sprintf("%s.%s", name, "15min"), | ||
Value: m.Rate15(), | ||
Period: int64(self.Interval.Seconds()), | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: map[string]interface{}{ | ||
DisplayUnitsLong: Operations, | ||
DisplayUnitsShort: OperationsShort, | ||
|
@@ -184,23 +184,23 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
Max: float64(m.Max()), | ||
Min: float64(m.Min()), | ||
SumSquares: sumSquaresTimer(m), | ||
Period: int64(self.Interval.Seconds()), | ||
Attributes: self.TimerAttributes, | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: rep.TimerAttributes, | ||
} | ||
for i, p := range self.Percentiles { | ||
for i, p := range rep.Percentiles { | ||
gauges[i+1] = Measurement{ | ||
Name: fmt.Sprintf("%s.timer.%2.0f", name, p*100), | ||
Value: m.Percentile(p), | ||
Period: int64(self.Interval.Seconds()), | ||
Attributes: self.TimerAttributes, | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: rep.TimerAttributes, | ||
} | ||
} | ||
snapshot.Gauges = append(snapshot.Gauges, gauges...) | ||
snapshot.Gauges = append(snapshot.Gauges, | ||
Measurement{ | ||
Name: fmt.Sprintf("%s.%s", name, "rate.1min"), | ||
Value: m.Rate1(), | ||
Period: int64(self.Interval.Seconds()), | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: map[string]interface{}{ | ||
DisplayUnitsLong: Operations, | ||
DisplayUnitsShort: OperationsShort, | ||
|
@@ -210,7 +210,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
Measurement{ | ||
Name: fmt.Sprintf("%s.%s", name, "rate.5min"), | ||
Value: m.Rate5(), | ||
Period: int64(self.Interval.Seconds()), | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: map[string]interface{}{ | ||
DisplayUnitsLong: Operations, | ||
DisplayUnitsShort: OperationsShort, | ||
|
@@ -220,7 +220,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
Measurement{ | ||
Name: fmt.Sprintf("%s.%s", name, "rate.15min"), | ||
Value: m.Rate15(), | ||
Period: int64(self.Interval.Seconds()), | ||
Period: int64(rep.Interval.Seconds()), | ||
Attributes: map[string]interface{}{ | ||
DisplayUnitsLong: Operations, | ||
DisplayUnitsShort: OperationsShort, | ||
|
@@ -232,4 +232,4 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot | |
} | ||
}) | ||
return | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please leave the newline at the end of the file. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave the newline at the end of the file.