|
@@ -45,8 +45,9 @@ type DotConfig struct {
|
45
|
45
|
Title string // The title of the DOT graph
|
46
|
46
|
Labels []string // The labels for the DOT's legend
|
47
|
47
|
|
48
|
|
- FormatValue func(int64) string // A formatting function for values
|
49
|
|
- Total int64 // The total weight of the graph, used to compute percentages
|
|
48
|
+ FormatValue func(int64) string // A formatting function for values
|
|
49
|
+ FormatTag func(int64, string) string // A formatting function for numeric tags
|
|
50
|
+ Total int64 // The total weight of the graph, used to compute percentages
|
50
|
51
|
}
|
51
|
52
|
|
52
|
53
|
// Compose creates and writes a in the DOT format to the writer, using
|
|
@@ -258,7 +259,7 @@ func (b *builder) numericNodelets(nts []*Tag, maxNumNodelets int, flatTags bool,
|
258
|
259
|
|
259
|
260
|
// Collapse numeric labels into maxNumNodelets buckets, of the form:
|
260
|
261
|
// 1MB..2MB, 3MB..5MB, ...
|
261
|
|
- for j, t := range collapsedTags(nts, maxNumNodelets, flatTags) {
|
|
262
|
+ for j, t := range b.collapsedTags(nts, maxNumNodelets, flatTags) {
|
262
|
263
|
w, attr := t.CumValue(), ` style="dotted"`
|
263
|
264
|
if flatTags || t.FlatValue() == t.CumValue() {
|
264
|
265
|
w, attr = t.FlatValue(), ""
|
|
@@ -399,7 +400,7 @@ func multilinePrintableName(info *NodeInfo) string {
|
399
|
400
|
}
|
400
|
401
|
|
401
|
402
|
// collapsedTags trims and sorts a slice of tags.
|
402
|
|
-func collapsedTags(ts []*Tag, count int, flatTags bool) []*Tag {
|
|
403
|
+func (b *builder) collapsedTags(ts []*Tag, count int, flatTags bool) []*Tag {
|
403
|
404
|
ts = SortTags(ts, flatTags)
|
404
|
405
|
if len(ts) <= count {
|
405
|
406
|
return ts
|
|
@@ -421,7 +422,7 @@ func collapsedTags(ts []*Tag, count int, flatTags bool) []*Tag {
|
421
|
422
|
|
422
|
423
|
var nts []*Tag
|
423
|
424
|
for _, g := range tagGroups {
|
424
|
|
- l, w, c := tagGroupLabel(g)
|
|
425
|
+ l, w, c := b.tagGroupLabel(g)
|
425
|
426
|
nts = append(nts, &Tag{
|
426
|
427
|
Name: l,
|
427
|
428
|
Flat: w,
|
|
@@ -439,10 +440,15 @@ func tagDistance(t, u *Tag) float64 {
|
439
|
440
|
return v - float64(t.Value)
|
440
|
441
|
}
|
441
|
442
|
|
442
|
|
-func tagGroupLabel(g []*Tag) (label string, flat, cum int64) {
|
|
443
|
+func (b *builder) tagGroupLabel(g []*Tag) (label string, flat, cum int64) {
|
|
444
|
+ formatTag := b.config.FormatTag
|
|
445
|
+ if formatTag == nil {
|
|
446
|
+ formatTag = measurement.Label
|
|
447
|
+ }
|
|
448
|
+
|
443
|
449
|
if len(g) == 1 {
|
444
|
450
|
t := g[0]
|
445
|
|
- return measurement.Label(t.Value, t.Unit), t.FlatValue(), t.CumValue()
|
|
451
|
+ return formatTag(t.Value, t.Unit), t.FlatValue(), t.CumValue()
|
446
|
452
|
}
|
447
|
453
|
min := g[0]
|
448
|
454
|
max := g[0]
|
|
@@ -466,7 +472,7 @@ func tagGroupLabel(g []*Tag) (label string, flat, cum int64) {
|
466
|
472
|
if dc != 0 {
|
467
|
473
|
c = c / dc
|
468
|
474
|
}
|
469
|
|
- return measurement.Label(min.Value, min.Unit) + ".." + measurement.Label(max.Value, max.Unit), f, c
|
|
475
|
+ return formatTag(min.Value, min.Unit) + ".." + formatTag(max.Value, max.Unit), f, c
|
470
|
476
|
}
|
471
|
477
|
|
472
|
478
|
func min64(a, b int64) int64 {
|