Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added trace style #5

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions pkg/browser/correlate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ import (
// correlate web page handler.
type correlate struct {
URL *url.URL

// URL Query parameter fields

Start string // Start query
Goal string // Goal class or neighbourhood depth

// Computed fields used by page template.

Depth int
Graph *Graph
Diagram, DiagramTxt, DiagramImg string
ConsoleURL *url.URL
UpdateTime time.Duration

// Other context

Err error // Accumulated errors from template.
Browser *Browser
}
Expand Down Expand Up @@ -128,11 +132,12 @@ func (c *correlate) update(req *http.Request) {
}

var domainAttrs = map[string]Attrs{
"k8s": {"shape": "octagon", "fillcolor": "#326CE5", "fontcolor": "white"},
"log": {"shape": "note", "fillcolor": "goldenrod", "fontname": "Courier"},
"alert": {"shape": "triangle", "fillcolor": "yellow"},
"metric": {"shape": "oval", "fillcolor": "wheat"},
"netobserv": {"shape": "rectangle", "fillcolor": "brick"},
"k8s": {"shape": "septagon", "fillcolor": "#326CE5", "fontcolor": "white"},
"log": {"shape": "note", "fillcolor": "yellow"},
"alert": {"shape": "triangle", "fillcolor": "yellow"},
"metric": {"shape": "egg", "fillcolor": "wheat"},
"netflow": {"shape": "component", "fillcolor": "skyblue"},
"trace": {"shape": "folder", "fillcolor": "aquamarine"},
}

func nodeToolTip(g *Graph, n *Node) string {
Expand Down Expand Up @@ -161,15 +166,12 @@ func nodeToolTip(g *Graph, n *Node) string {

// updateDiagram generates an SVG diagram via graphviz.
func (c *correlate) updateDiagram() {
if c.Depth > 0 {
c.Graph.GraphAttrs["layout"] = "twopi"
}
nodes := c.Graph.Nodes()
for nodes.Next() {
n := nodes.Node().(*Node)
count := n.Model.Count
a := n.Attrs
a["style"] += "filled"
a["style"] = "filled"
a["label"] = fmt.Sprintf("%v\n%v", n.Model.Class, count)
a["tooltip"] = nodeToolTip(c.Graph, n)
maps.Copy(a, domainAttrs[strings.SplitN(n.Model.Class, ":", 2)[0]])
Expand Down
9 changes: 3 additions & 6 deletions pkg/browser/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ func NewGraph(mg *models.Graph) *Graph {
DirectedGraph: simple.NewDirectedGraph(),
Model: mg,
GraphAttrs: Attrs{
"fontname": "Helvetica",
"fontsize": "12",
"splines": "true",
"overlap": "prism",
"overlap_scaling": "-2",
"layout": "dot",
"fontname": "Helvetica",
"fontsize": "10",
"layout": "dot",
},
NodeAttrs: Attrs{
"fontname": "Helveticax",
Expand Down
4 changes: 2 additions & 2 deletions pkg/browser/templates/correlate.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<input type="text" id="goal" name="goal" value="{{.Goal}}" size="50" accesskey="k">
<br>
</div>
<p>
<div>
<input type="submit" id="submit" value="Update Graph">
<span id="waiting" style="display:none;"><img src="images/gears.gif" id="loading"></span>
</p>
</div>
</form>

<script type="text/javascript">
Expand Down
Loading