This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
/
init_metrics.go
73 lines (63 loc) · 2.6 KB
/
init_metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package horizon
import (
"fmt"
"github.com/rcrowley/go-metrics"
"github.com/stellar/horizon/log"
)
func initMetrics(app *App) {
app.metrics = metrics.NewRegistry()
}
func initDbMetrics(app *App) {
app.historyLatestLedgerGauge = metrics.NewGauge()
app.historyElderLedgerGauge = metrics.NewGauge()
app.coreLatestLedgerGauge = metrics.NewGauge()
app.coreElderLedgerGauge = metrics.NewGauge()
app.horizonConnGauge = metrics.NewGauge()
app.coreConnGauge = metrics.NewGauge()
app.goroutineGauge = metrics.NewGauge()
app.metrics.Register("history.latest_ledger", app.historyLatestLedgerGauge)
app.metrics.Register("history.elder_ledger", app.historyElderLedgerGauge)
app.metrics.Register("stellar_core.latest_ledger", app.coreLatestLedgerGauge)
app.metrics.Register("stellar_core.elder_ledger", app.coreElderLedgerGauge)
app.metrics.Register("history.open_connections", app.horizonConnGauge)
app.metrics.Register("stellar_core.open_connections", app.coreConnGauge)
app.metrics.Register("goroutines", app.goroutineGauge)
}
func initIngesterMetrics(app *App) {
if app.ingester == nil {
return
}
app.metrics.Register("ingester.ingest_ledger",
app.ingester.Metrics.IngestLedgerTimer)
app.metrics.Register("ingester.clear_ledger",
app.ingester.Metrics.ClearLedgerTimer)
}
func initLogMetrics(app *App) {
for level, meter := range *log.DefaultMetrics {
key := fmt.Sprintf("logging.%s", level)
app.metrics.Register(key, meter)
}
}
func initTxSubMetrics(app *App) {
app.submitter.Init()
app.metrics.Register("txsub.buffered", app.submitter.Metrics.BufferedSubmissionsGauge)
app.metrics.Register("txsub.open", app.submitter.Metrics.OpenSubmissionsGauge)
app.metrics.Register("txsub.succeeded", app.submitter.Metrics.SuccessfulSubmissionsMeter)
app.metrics.Register("txsub.failed", app.submitter.Metrics.FailedSubmissionsMeter)
app.metrics.Register("txsub.total", app.submitter.Metrics.SubmissionTimer)
}
// initWebMetrics registers the metrics for the web server into the provided
// app's metrics registry.
func initWebMetrics(app *App) {
app.metrics.Register("requests.total", app.web.requestTimer)
app.metrics.Register("requests.succeeded", app.web.successMeter)
app.metrics.Register("requests.failed", app.web.failureMeter)
}
func init() {
appInit.Add("metrics", initMetrics)
appInit.Add("log.metrics", initLogMetrics, "metrics")
appInit.Add("db-metrics", initDbMetrics, "metrics", "horizon-db", "core-db")
appInit.Add("web.metrics", initWebMetrics, "web.init", "metrics")
appInit.Add("txsub.metrics", initTxSubMetrics, "txsub", "metrics")
appInit.Add("ingester.metrics", initIngesterMetrics, "ingester", "metrics")
}