Skip to content

Commit

Permalink
Fix traffic graph
Browse files Browse the repository at this point in the history
After we introduced system components (weavelet control and deployment
control), the traffic graph doesn't display anything in the weaver multi
dashboard.

This is because when we display the graph, we look at the components
of the application and then we try to match them to the traffic between
them. However, the edges show traffic for components that are missing from the
status (e.g., the system components). Hence, when we display the graph
there is no 1:1 mapping between components and the traffic between
them.

This PR fixes this issue by not displaying traffic for system
components (in fact the user shouldn't care about that). Maybe a better
fix would be to do this in the javascript itself, but we can do that in
the future if needed.
  • Loading branch information
rgrandl committed Aug 23, 2024
1 parent d613ffe commit 604488a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/go/bin/staticcheck
key: staticcheck-v0.4.6
key: staticcheck-v0.5.0
if: ${{ matrix.command == 'lint' }}

- name: Install linter
Expand Down
1 change: 1 addition & 0 deletions godeps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ github.com/ServiceWeaver/weaver/internal/status
errors
flag
fmt
github.com/ServiceWeaver/weaver/internal/control
github.com/ServiceWeaver/weaver/internal/files
github.com/ServiceWeaver/weaver/internal/metrics
github.com/ServiceWeaver/weaver/internal/traceio
Expand Down
14 changes: 12 additions & 2 deletions internal/status/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"strings"
"time"

"github.com/ServiceWeaver/weaver/internal/control"
metrics2 "github.com/ServiceWeaver/weaver/internal/metrics"
"github.com/ServiceWeaver/weaver/internal/traceio"
"github.com/ServiceWeaver/weaver/runtime/logging"
Expand Down Expand Up @@ -265,14 +266,23 @@ func computeTraffic(status *Status, metrics []*protos.MetricSnapshot) []edge {
caller string
component string
}
isSystemComponentFn := func(name string) bool {
return name == control.WeaveletPath || name == control.DeployerPath
}
byPair := map[pair]int{}
for _, metric := range metrics {
if metric.Name != metrics2.MethodCountsName {
continue
}
caller := metric.Labels["caller"]
component := metric.Labels["component"]
if isSystemComponentFn(caller) || isSystemComponentFn(component) {
// Don't display traffic information for the internal system components.
continue
}
call := pair{
caller: metric.Labels["caller"],
component: metric.Labels["component"],
caller: caller,
component: component,
}
byPair[call] += int(metric.Value)
}
Expand Down

0 comments on commit 604488a

Please sign in to comment.