Skip to content

Commit

Permalink
Merged pull request influxdata#1236 from influxdata/nc-issue#1068
Browse files Browse the repository at this point in the history
Dot labels are make use of xlabel and fix quoting issues
  • Loading branch information
nathanielc committed Mar 14, 2017
2 parents 5c54c02 + f3f1b1b commit 92df21d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- [#1192](https://github.com/influxdata/kapacitor/issues/1192): Fix bug in Default Node not updating batch tags and groupID.
Also empty string on a tag value is now a sufficient condition for the default conditions to be applied.
See [#1233](https://github.com/influxdata/kapacitor/pull/1233) for more information.
- [#1068](https://github.com/influxdata/kapacitor/issues/1068): Fix dot view syntax to use xlabels and not create invalid quotes.

## v1.2.0 [2017-01-23]

Expand Down
29 changes: 20 additions & 9 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,36 @@ func (n *node) closeChildEdges() {
func (n *node) edot(buf *bytes.Buffer, labels bool) {
if labels {
// Print all stats on node.
buf.Write([]byte(
fmt.Sprintf("\n%s [label=\"%s ",
n.Name(),
buf.WriteString(
fmt.Sprintf("\n%s [xlabel=\"",
n.Name(),
),
))
)
i := 0
n.statMap.DoSorted(func(kv expvar.KeyValue) {
buf.Write([]byte(
fmt.Sprintf("%s=%s ",
if i != 0 {
// NOTE: A literal \r, indicates a newline right justified in graphviz syntax.
buf.WriteString(`\r`)
}
i++
var s string
if sv, ok := kv.Value.(kexpvar.StringVar); ok {
s = sv.StringValue()
} else {
s = kv.Value.String()
}
buf.WriteString(
fmt.Sprintf("%s=%s",
kv.Key,
kv.Value.String(),
s,
),
))
)
})
buf.Write([]byte("\"];\n"))

for i, c := range n.children {
buf.Write([]byte(
fmt.Sprintf("%s -> %s [label=\"%d\"];\n",
fmt.Sprintf("%s -> %s [label=\"processed=%d\"];\n",
n.Name(),
c.Name(),
n.outs[i].collectedCount(),
Expand Down
20 changes: 11 additions & 9 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,29 +371,31 @@ func (et *ExecutingTask) EDot(labels bool) []byte {

var buf bytes.Buffer

buf.Write([]byte("digraph "))
buf.Write([]byte(et.Task.ID))
buf.Write([]byte(" {\n"))
buf.WriteString("digraph ")
buf.WriteString(et.Task.ID)
buf.WriteString(" {\n")
// Write graph attributes
unit := "points"
if et.Task.Type == BatchTask {
unit = "batches"
}
buf.WriteString("graph [")
if labels {
buf.Write([]byte(
fmt.Sprintf("graph [label=\"Throughput: %0.2f %s/s\"];\n",
buf.WriteString(
fmt.Sprintf("label=\"Throughput: %0.2f %s/s\" forcelabels=true pad=\"0.8,0.5\"",
et.getThroughput(),
unit,
),
))
)
} else {
buf.Write([]byte(
fmt.Sprintf("graph [throughput=\"%0.2f %s/s\"];\n",
buf.WriteString(
fmt.Sprintf("throughput=\"%0.2f %s/s\"",
et.getThroughput(),
unit,
),
))
)
}
buf.WriteString("];\n")

_ = et.walk(func(n Node) error {
n.edot(&buf, labels)
Expand Down

0 comments on commit 92df21d

Please sign in to comment.