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

Add trafficsplit metrics to CLI #3176

Merged
merged 21 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixing lint errors
  • Loading branch information
Carol Scott committed Aug 14, 2019
commit a1a7af605e9d259f8f7b28a2d5e6c384b72d4d28
2 changes: 1 addition & 1 deletion cli/cmd/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ var (
isTrafficSplit = false
)

var key, leafName, apexName, weight string
var leafName, apexName, weight string
scottcarol marked this conversation as resolved.
Show resolved Hide resolved

func writeStatsToBuffer(rows []*pb.StatTable_PodGroup_Row, w *tabwriter.Writer, options *statOptions) {
maxNameLength := len(nameHeader)
Expand Down
8 changes: 4 additions & 4 deletions controller/api/public/stat_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (s *grpcServer) trafficSplitResourceQuery(ctx context.Context, req *pb.Stat

var tsBasicStats map[tsKey]*pb.BasicStats
if !req.SkipStats {
tsBasicStats, _, err = s.getTrafficSplitMetrics(ctx, req, k8sObjects, req.TimeWindow)
tsBasicStats, err = s.getTrafficSplitMetrics(ctx, req, k8sObjects, req.TimeWindow)

if err != nil {
scottcarol marked this conversation as resolved.
Show resolved Hide resolved
return resourceResult{res: nil, err: err}
Expand Down Expand Up @@ -529,7 +529,7 @@ func (s *grpcServer) getStatMetrics(ctx context.Context, req *pb.StatSummaryRequ
// however, the rKey.Name returned is the leaf service name due to the need to query Prometheus for dst_service,
// whereas the the rKey.Name in the k8sObject data is the trafficsplit name. in order to match the k8sObjects
scottcarol marked this conversation as resolved.
Show resolved Hide resolved
// to the Prometheus metrics, we return a new map[tsKey]*pb.BasicStats which includes apex and leaf information.
func (s *grpcServer) getTrafficSplitMetrics(ctx context.Context, req *pb.StatSummaryRequest, k8sObjects map[rKey]k8sStat, timeWindow string) (map[tsKey]*pb.BasicStats, map[tsKey]*pb.TcpStats, error) {
func (s *grpcServer) getTrafficSplitMetrics(ctx context.Context, req *pb.StatSummaryRequest, k8sObjects map[rKey]k8sStat, timeWindow string) (map[tsKey]*pb.BasicStats, error) {
scottcarol marked this conversation as resolved.
Show resolved Hide resolved

scottcarol marked this conversation as resolved.
Show resolved Hide resolved
tsBasicStats := make(map[tsKey]*pb.BasicStats)

Expand All @@ -551,7 +551,7 @@ func (s *grpcServer) getTrafficSplitMetrics(ctx context.Context, req *pb.StatSum
results, err := s.getPrometheusMetrics(ctx, promQueries, latencyQuantileQuery, stringifiedReqLabels, timeWindow, groupBy.String())

if err != nil {
return nil, nil, err
return nil, err
}

basicStats, _ := processPrometheusMetrics(req, results, groupBy) // we don't need tcpStat info for traffic split
Expand All @@ -566,7 +566,7 @@ func (s *grpcServer) getTrafficSplitMetrics(ctx context.Context, req *pb.StatSum
}] = basicStatsVal
}
}
return tsBasicStats, nil, nil
return tsBasicStats, nil
}

func processPrometheusMetrics(req *pb.StatSummaryRequest, results []promResult, groupBy model.LabelNames) (map[rKey]*pb.BasicStats, map[rKey]*pb.TcpStats) {
Expand Down