Skip to content

Commit 5bf6eb1

Browse files
authored
Merge pull request #405 from m-lab/pollution-metrics
add metrics for pollution.
2 parents d9f1442 + b74aa7f commit 5bf6eb1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

metrics/metrics.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func init() {
3232
prometheus.MustRegister(PTMoreHopsAfterDest)
3333
prometheus.MustRegister(PTBitsAwayFromDestV4)
3434
prometheus.MustRegister(PTBitsAwayFromDestV6)
35+
prometheus.MustRegister(PTPollutedCount)
3536
prometheus.MustRegister(ErrorCount)
3637
prometheus.MustRegister(WarningCount)
3738
prometheus.MustRegister(BackendFailureCount)
@@ -266,6 +267,21 @@ var (
266267
[]string{"metro"},
267268
)
268269

270+
// Counts the PT polluted tests per metro.
271+
//
272+
// Provides metrics:
273+
// etl_pt_polluted_total{metro}
274+
// Example usage:
275+
// metrics.PTPollutedCount.WithLabelValues("sea").Inc()
276+
PTPollutedCount = prometheus.NewCounterVec(
277+
prometheus.CounterOpts{
278+
Name: "etl_pt_polluted_total",
279+
Help: "Count how many PT tests polluted per metro.",
280+
},
281+
// sea
282+
[]string{"metro"},
283+
)
284+
269285
// Counts the all warnings that do NOT result in test loss.
270286
//
271287
// Provides metrics:

parser/pt.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type cachedPTData struct {
4040
LogTime time.Time
4141
ConnSpec *schema.MLabConnectionSpecification
4242
LastValidHopLine string
43+
MetroName string
4344
}
4445

4546
type PTParser struct {
@@ -278,7 +279,8 @@ func (pt *PTParser) ParseAndInsert(meta map[string]bigquery.Value, testName stri
278279
// (in func ProcessAllNodes()). So the final parsed hop is Hops[0].
279280
finalHop := PTTest.Hops[0]
280281
if PTTest.ConnSpec.Client_ip != destIP && (finalHop.Dest_ip == destIP || strings.Contains(PTTest.LastValidHopLine, destIP)) {
281-
// Discard pt.previousTest[index]
282+
// Discard pt.previousTests[index]
283+
metrics.PTPollutedCount.WithLabelValues(pt.previousTests[index].MetroName).Inc()
282284
pt.previousTests = append(pt.previousTests[:index], pt.previousTests[index+1:]...)
283285
break
284286
}
@@ -566,5 +568,6 @@ func Parse(meta map[string]bigquery.Value, testName string, testId string, rawCo
566568
LogTime: logTime,
567569
ConnSpec: connSpec,
568570
LastValidHopLine: lastValidHopLine,
571+
MetroName: metroName,
569572
}, nil
570573
}

0 commit comments

Comments
 (0)