godev/cmd/worker: don't include buckets in the chart ID
Right now, when you click on a specific chart in the chart browser, it
updates the location to include the full counter line, including
buckets. The buckets are suppressed in the chart name only due to a
template func that trims them.
But buckets are not relevant to the identity of the chart, and result in
a very long URL. Trim the ID to only include the counter prefix.
Change-Id: Iddd1a932df4f44beb490e7225208d9c476ca7e56
Reviewed-on: https://go-review.googlesource.com/c/telemetry/+/611841
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
diff --git a/godev/cmd/worker/main.go b/godev/cmd/worker/main.go
index 7e58193..d3296bd 100644
--- a/godev/cmd/worker/main.go
+++ b/godev/cmd/worker/main.go
@@ -421,14 +421,14 @@
// partition builds a chart for the program and the counter. It can return nil
// if there is no data for the counter in dat.
-func (d data) partition(program, counterPrefix string, counters []string) *chart {
+func (d data) partition(program, counter string, counters []string) *chart {
+ prefix, _ := splitCounterName(counter)
count := &chart{
- ID: "charts:" + program + ":" + counterPrefix,
- Name: counterPrefix,
+ ID: "charts:" + program + ":" + prefix,
+ Name: prefix,
Type: "partition",
}
pk := programName(program)
- prefix, _ := splitCounterName(counterPrefix)
gk := graphName(prefix)
var (
@@ -449,7 +449,7 @@
seen := make(map[string]bool)
for _, b := range counters {
// TODO(hyangah): let caller normalize names in counters.
- counter := normalizeCounterName(counterPrefix, b)
+ counter := normalizeCounterName(counter, b)
if seen[counter] {
continue
}
diff --git a/godev/cmd/worker/main_test.go b/godev/cmd/worker/main_test.go
index ba052ca..b01720e 100644
--- a/godev/cmd/worker/main_test.go
+++ b/godev/cmd/worker/main_test.go
@@ -526,9 +526,10 @@
{
Name: "example.com/mod/pkg",
Versions: []string{"v0.15.0"},
- Counters: []telemetry.CounterConfig{{
- Name: "count2",
- }},
+ Counters: []telemetry.CounterConfig{
+ {Name: "count2"},
+ {Name: "flag:{a,b,c}"},
+ },
},
},
},
@@ -630,6 +631,16 @@
Value: 2,
}},
},
+ {
+ ID: "charts:example.com/mod/pkg:flag",
+ Name: "flag",
+ Type: "partition",
+ Data: []*datum{
+ {Week: "2999-01-01", Key: "a", Value: 2},
+ {Week: "2999-01-01", Key: "b", Value: 2},
+ {Week: "2999-01-01", Key: "c", Value: 1},
+ },
+ },
},
},
},