added func getPercentile(t *topic, percentile int) float64

This commit is contained in:
Dnile
2016-05-30 14:43:03 -07:00
parent bf6bc73e11
commit 73be4f2a46
2 changed files with 13 additions and 2 deletions

View File

@ -66,6 +66,17 @@ type client struct {
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) {
resp, err := http.Get(nsqdURL)

View File

@ -42,7 +42,7 @@ func TopicStats(namespace string) StatsCollector {
}, 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{
Namespace: namespace,
Name: "e2e_latency_99_percentile",
@ -50,7 +50,7 @@ func TopicStats(namespace string) StatsCollector {
}, 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{
Namespace: namespace,
Name: "e2e_latency_95_percentile",