Skip to content

Commit

Permalink
Improve metrics definition inside metrics package.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Lucas authored and iknite committed Feb 19, 2019
1 parent 9af664c commit 324c321
Showing 1 changed file with 140 additions and 5 deletions.
145 changes: 140 additions & 5 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,38 @@ var (
Balloon *expvar.Map

// Prometheus
// API
Api_healthcheck_requests_total prometheus.Counter

// Balloon
Balloon_add_duration_seconds prometheus.Gauge
Balloon_membership_duration_seconds prometheus.Gauge
Balloon_digest_membership_duration_seconds prometheus.Gauge
Balloon_incremental_duration_seconds prometheus.Gauge

Balloon_add_total prometheus.Gauge
Balloon_membership_total prometheus.Gauge
Balloon_digest_membership_total prometheus.Gauge
Balloon_incremental_total prometheus.Gauge

// Agents
Sender_instances_count prometheus.Gauge
Auditor_instances_count prometheus.Gauge
Monitor_instances_count prometheus.Gauge
Publisher_instances_count prometheus.Gauge

Sender_batches_sent_total prometheus.Gauge
Auditor_batches_received_total prometheus.Gauge
Monitor_batches_received_total prometheus.Gauge
Publisher_batches_received_total prometheus.Gauge

Auditor_batches_process_seconds prometheus.Gauge
Monitor_batches_process_seconds prometheus.Gauge
Publisher_batches_process_seconds prometheus.Gauge

// Example
FuncDuration prometheus.Gauge
RequestDuration prometheus.Histogram
OpsProcessed prometheus.Counter
)

// Implement expVar.Var interface
Expand All @@ -47,7 +76,11 @@ func (v Uint64ToVar) String() string {
func init() {
Hyper = expvar.NewMap("hyper_stats")
History = expvar.NewMap("history_stats")
Balloon = expvar.NewMap("balloon_stats")
Balloon = expvar.NewMap("Balloon_stats")

apiMetrics()
balloonMetrics()
agentMetrics()

FuncDuration = promauto.NewGauge(prometheus.GaugeOpts{
Name: "example_function_duration_seconds",
Expand All @@ -59,10 +92,112 @@ func init() {
Help: "Histogram for the runtime of a simple example function.",
Buckets: prometheus.LinearBuckets(0.01, 0.01, 10),
})
}

func apiMetrics() {
Api_healthcheck_requests_total = promauto.NewCounter(prometheus.CounterOpts{
Name: "Api_healthcheck_requests_total",
Help: "The total number of healthcheck api requests",
})
}

func balloonMetrics() {

Balloon_add_duration_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_add_duration_seconds",
Help: "Duration of the 'Add' balloon method.",
})

Balloon_membership_duration_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_membership_duration_seconds",
Help: "Duration of the 'Membership' balloon method.",
})

Balloon_digest_membership_duration_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_digest_membership_duration_seconds",
Help: "Duration of the 'Digest Membership' balloon method",
})

Balloon_incremental_duration_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_incremental_duration_seconds",
Help: "Duration of the 'Incremental' balloon method.",
})

Balloon_add_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_add_total",
Help: "Duration of the last call of an example function.",
})

Balloon_membership_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_membership_total",
Help: "Duration of the last call of an example function.",
})

Balloon_digest_membership_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_digest_membership_total",
Help: "Duration of the last call of an example function.",
})

Balloon_incremental_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Balloon_incremental_total",
Help: "Duration of the last call of an example function.",
})
}

func agentMetrics() {

Sender_instances_count = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Sender_instances_count",
Help: "Duration of the last call of an example function.",
})

Auditor_instances_count = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Auditor_instances_count",
Help: "Duration of the last call of an example function.",
})

Monitor_instances_count = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Monitor_instances_count",
Help: "Duration of the last call of an example function.",
})

Publisher_instances_count = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Publisher_instances_count",
Help: "Duration of the last call of an example function.",
})

Sender_batches_sent_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Sender_batches_sent_total",
Help: "Duration of the last call of an example function.",
})

Auditor_batches_received_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Auditor_batches_received_total",
Help: "Duration of the last call of an example function.",
})

Monitor_batches_received_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Monitor_batches_received_total",
Help: "Duration of the last call of an example function.",
})

Publisher_batches_received_total = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Publisher_batches_received_total",
Help: "Duration of the last call of an example function.",
})

Auditor_batches_process_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Auditor_batches_process_seconds",
Help: "Duration of the last call of an example function.",
})

OpsProcessed = promauto.NewCounter(prometheus.CounterOpts{
Name: "qed_healthcheck_ops_total",
Help: "The total number of processed events",
Monitor_batches_process_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Monitor_batches_process_seconds",
Help: "Duration of the last call of an example function.",
})

Publisher_batches_process_seconds = promauto.NewGauge(prometheus.GaugeOpts{
Name: "Publisher_batches_process_seconds",
Help: "Duration of the last call of an example function.",
})
}

0 comments on commit 324c321

Please sign in to comment.