added func getPercentile(t *topic, percentile int) float64
This commit is contained in:
@ -66,6 +66,17 @@ type client struct {
|
|||||||
TLS bool `json:"tls"`
|
TLS bool `json:"tls"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPercentile(t *topic, percentile int) float64 {
|
||||||
|
if len(t.E2eLatency.Percentiles) > 0 {
|
||||||
|
if percentile == 99 {
|
||||||
|
return t.E2eLatency.Percentiles[0]["value"]
|
||||||
|
} else if percentile == 95 {
|
||||||
|
return t.E2eLatency.Percentiles[1]["value"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func getNsqdStats(nsqdURL string) (*stats, error) {
|
func getNsqdStats(nsqdURL string) (*stats, error) {
|
||||||
|
|
||||||
resp, err := http.Get(nsqdURL)
|
resp, err := http.Get(nsqdURL)
|
||||||
|
@ -42,7 +42,7 @@ func TopicStats(namespace string) StatsCollector {
|
|||||||
}, labels),
|
}, labels),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
val: func(t *topic) float64 { return t.E2eLatency.Percentiles[0]["value"] },
|
val: func(t *topic) float64 { return getPercentile(t, 99) },
|
||||||
vec: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
vec: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: "e2e_latency_99_percentile",
|
Name: "e2e_latency_99_percentile",
|
||||||
@ -50,7 +50,7 @@ func TopicStats(namespace string) StatsCollector {
|
|||||||
}, labels),
|
}, labels),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
val: func(t *topic) float64 { return t.E2eLatency.Percentiles[1]["value"] },
|
val: func(t *topic) float64 { return getPercentile(t, 95) },
|
||||||
vec: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
vec: prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: "e2e_latency_95_percentile",
|
Name: "e2e_latency_95_percentile",
|
||||||
|
Reference in New Issue
Block a user