Skip to content

Commit

Permalink
Add objectives in prometheus metrics because default objectives are d…
Browse files Browse the repository at this point in the history
…eprecated in the updated version of prometheus go client. (#5092)
  • Loading branch information
urvisavla authored Oct 27, 2023
1 parent a3f37f4 commit 3949234
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ingest/ledgerbackend/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func WithMetrics(base LedgerBackend, registry *prometheus.Registry, namespace st
summary := prometheus.NewSummary(
prometheus.SummaryOpts{
Namespace: namespace, Subsystem: "ingest", Name: "ledger_fetch_duration_seconds",
Help: "duration of fetching ledgers from ledger backend, sliding window = 10m",
Help: "duration of fetching ledgers from ledger backend, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
)
registry.MustRegister(summary)
Expand Down
3 changes: 2 additions & 1 deletion services/horizon/internal/httpx/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func NewServer(serverConfig ServerConfig, routerConfig RouterConfig, ledgerState
RequestDurationSummary: prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "http", Name: "requests_duration_seconds",
Help: "HTTP requests durations, sliding window = 10m",
Help: "HTTP requests durations, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"status", "route", "streaming", "method"},
),
Expand Down
15 changes: 10 additions & 5 deletions services/horizon/internal/ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,22 +336,26 @@ func (s *system) initMetrics() {

s.metrics.LedgerIngestionDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "ingest", Name: "ledger_ingestion_duration_seconds",
Help: "ledger ingestion durations, sliding window = 10m",
Help: "ledger ingestion durations, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
})

s.metrics.LedgerIngestionTradeAggregationDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "ingest", Name: "ledger_ingestion_trade_aggregation_duration_seconds",
Help: "ledger ingestion trade aggregation rebuild durations, sliding window = 10m",
Help: "ledger ingestion trade aggregation rebuild durations, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
})

s.metrics.LedgerIngestionReapLookupTablesDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "ingest", Name: "ledger_ingestion_reap_lookup_tables_duration_seconds",
Help: "ledger ingestion reap lookup tables durations, sliding window = 10m",
Help: "ledger ingestion reap lookup tables durations, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
})

s.metrics.StateVerifyDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "ingest", Name: "state_verify_duration_seconds",
Help: "state verification durations, sliding window = 10m",
Help: "state verification durations, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
})

s.metrics.StateInvalidGauge = prometheus.NewGaugeFunc(
Expand Down Expand Up @@ -400,7 +404,8 @@ func (s *system) initMetrics() {
s.metrics.ProcessorsRunDurationSummary = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "ingest", Name: "processor_run_duration_seconds",
Help: "run durations of ingestion processors, sliding window = 10m",
Help: "run durations of ingestion processors, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"name"},
)
Expand Down
3 changes: 2 additions & 1 deletion services/horizon/internal/txsub/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ func (sys *System) Init() {

sys.Metrics.SubmissionDuration = prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "horizon", Subsystem: "txsub", Name: "submission_duration_seconds",
Help: "submission durations to Stellar-Core, sliding window = 10m",
Help: "submission durations to Stellar-Core, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
})
sys.Metrics.FailedSubmissionsCounter = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "horizon", Subsystem: "txsub", Name: "failed",
Expand Down
2 changes: 2 additions & 0 deletions support/db/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func RegisterMetrics(base *Session, namespace string, sub Subservice, registry *
Namespace: namespace, Subsystem: "db",
Name: "query_duration_seconds",
ConstLabels: prometheus.Labels{"subservice": string(sub)},
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"query_type", "error", "route"},
)
Expand Down Expand Up @@ -232,6 +233,7 @@ func RegisterMetrics(base *Session, namespace string, sub Subservice, registry *
Name: "round_trip_time_seconds",
Help: "time required to run `select 1` query in a DB - effectively measures round trip time, if time exceeds 1s it will be recorded as 1",
ConstLabels: prometheus.Labels{"subservice": string(sub)},
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
)
registry.MustRegister(s.roundTripTimeSummary)
Expand Down

0 comments on commit 3949234

Please sign in to comment.