-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added httpd status counters collection and reporting.
- Loading branch information
Showing
2 changed files
with
100 additions
and
9 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,33 @@ | ||
package gorelic | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/yvasiyarov/go-metrics" | ||
"github.com/yvasiyarov/newrelic_platform_go" | ||
) | ||
|
||
// New metrica collector - counter per each http status code. | ||
type counterByStatusMetrica struct { | ||
counter metrics.Counter | ||
name string | ||
units string | ||
} | ||
|
||
// metrics.IMetrica interface implementation. | ||
func (m *counterByStatusMetrica) GetName() string { return m.name } | ||
|
||
func (m *counterByStatusMetrica) GetUnits() string { return m.units } | ||
|
||
func (m *counterByStatusMetrica) GetValue() (float64, error) { return float64(m.counter.Count()), nil } | ||
|
||
// addHTTPStatusMetricsToComponent initializes counter metrics for all http statuses and adds them to the component. | ||
func addHTTPStatusMetricsToComponent(component newrelic_platform_go.IComponent, statusCounters map[int]metrics.Counter) { | ||
for statusCode, counter := range statusCounters { | ||
component.AddMetrica(&counterByStatusMetrica{ | ||
counter: counter, | ||
name: fmt.Sprintf("http/status/%d", statusCode), | ||
units: "count", | ||
}) | ||
} | ||
} |