-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
302 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package core | ||
|
||
// Announcement represents a message to be shouted out | ||
type Announcement interface { | ||
Title() string | ||
Text() string | ||
URL() string | ||
ShouldAnnounce() bool | ||
ProjectName() string | ||
} | ||
|
||
// Parser provides an interface that allows to identify if a request can be | ||
// parsed, and then will extract the announcement if there is any. | ||
type Parser interface { | ||
Match(map[string][]string) bool | ||
Parse([]byte) (Announcement, error) | ||
} | ||
|
||
// Announcer provides a simple interface to announce things | ||
type Announcer interface { | ||
Announce(Announcement) | ||
} |
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 @@ | ||
package github_test |
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
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,76 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
var namespace = "propaganda" | ||
|
||
// Metrics provided through prometheus | ||
var ( | ||
bootTime = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "boot_time_seconds", | ||
Help: "unix timestamp of when the service was started", | ||
}) | ||
|
||
Up = prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "up", | ||
Help: "wether the service is up or not", | ||
}) | ||
WebhooksReceived = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "webhooks", | ||
Name: "received_total", | ||
Help: "total number of received webhooks", | ||
}) | ||
WebhooksBytesRead = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "webhooks", | ||
Name: "bytes_read_total", | ||
Help: "total number of incoming bytes", | ||
}) | ||
WebhooksErrors = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "webhooks", | ||
Name: "errors_total", | ||
Help: "total number of webhooks errors", | ||
}) | ||
WebhooksInvalid = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "webhooks", | ||
Name: "invalid_total", | ||
Help: "total number of invalid webhooks", | ||
}, []string{"reason"}) | ||
WebhooksValid = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "webhooks", | ||
Name: "valid_total", | ||
Help: "total number of valid webhooks", | ||
}, []string{"project"}) | ||
AnnouncementSuccesses = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "announcer", | ||
Name: "success_total", | ||
Help: "total number of announcement successes", | ||
}) | ||
AnnouncementErrors = prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: "announcer", | ||
Name: "errors_total", | ||
Help: "total number of announcement errors", | ||
}) | ||
) | ||
|
||
// Register registers all the metrics and sets the http handler | ||
func Register(metricsPath string) { | ||
bootTime.Set(float64(time.Now().Unix())) | ||
Up.Set(0) | ||
|
||
prometheus.MustRegister(bootTime) | ||
|
||
http.Handle(metricsPath, prometheus.Handler()) | ||
} |
Oops, something went wrong.