mirror of https://github.com/matrix-org/go-neb.git
Browse Source
Merge pull request #91 from matrix-org/kegan/neb-metrics
Merge pull request #91 from matrix-org/kegan/neb-metrics
Add metrics to NEBkegan/rss-user-agent
Kegsay
8 years ago
committed by
GitHub
6 changed files with 108 additions and 6 deletions
-
7src/github.com/matrix-org/go-neb/api.go
-
1src/github.com/matrix-org/go-neb/goneb.go
-
50src/github.com/matrix-org/go-neb/metrics/metrics.go
-
4src/github.com/matrix-org/go-neb/plugin/plugin.go
-
19src/github.com/matrix-org/go-neb/services/guggy/guggy.go
-
31src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go
@ -0,0 +1,50 @@ |
|||
package metrics |
|||
|
|||
import ( |
|||
"github.com/prometheus/client_golang/prometheus" |
|||
) |
|||
|
|||
// Status is the status of a measurable metric (incoming commands, outgoing polls, etc)
|
|||
type Status string |
|||
|
|||
// Common status values
|
|||
const ( |
|||
StatusSuccess = "success" |
|||
StatusFailure = "failure" |
|||
) |
|||
|
|||
var ( |
|||
cmdCounter = prometheus.NewCounterVec(prometheus.CounterOpts{ |
|||
Name: "goneb_pling_cmd_total", |
|||
Help: "The number of incoming commands from matrix clients", |
|||
}, []string{"cmd", "status"}) |
|||
configureServicesCounter = prometheus.NewCounterVec(prometheus.CounterOpts{ |
|||
Name: "goneb_configure_services_total", |
|||
Help: "The total number of configured services requests", |
|||
}, []string{"service_type"}) |
|||
webhookCounter = prometheus.NewCounterVec(prometheus.CounterOpts{ |
|||
Name: "goneb_webhook_total", |
|||
Help: "The total number of recognised incoming webhook requests", |
|||
}, []string{"service_type"}) |
|||
) |
|||
|
|||
// IncrementCommand increments the pling command counter
|
|||
func IncrementCommand(cmdName string, st Status) { |
|||
cmdCounter.With(prometheus.Labels{"cmd": cmdName, "status": string(st)}).Inc() |
|||
} |
|||
|
|||
// IncrementConfigureService increments the /configureService counter
|
|||
func IncrementConfigureService(serviceType string) { |
|||
configureServicesCounter.With(prometheus.Labels{"service_type": serviceType}).Inc() |
|||
} |
|||
|
|||
// IncrementWebhook increments the incoming webhook request counter
|
|||
func IncrementWebhook(serviceType string) { |
|||
webhookCounter.With(prometheus.Labels{"service_type": serviceType}).Inc() |
|||
} |
|||
|
|||
func init() { |
|||
prometheus.MustRegister(cmdCounter) |
|||
prometheus.MustRegister(configureServicesCounter) |
|||
prometheus.MustRegister(webhookCounter) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue