Skip to content
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Release Notes.
- Remove `duration` flag in `profiling ebpf schedules`.(#150)
- [Breaking Change] Remove `total` field in `trace list` and `logs list` commands.(#152)
- [Breaking Change] Remove `total` field in `event list`, `browser logs list`, `alarm list` commands.(#153)
- Add `aggregate` flag in `profiling ebpf analysis` commands.(#154)

0.10.0
------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.

query ($scheduleIdList: [ID!]!, $timeRanges: [EBPFProfilingAnalyzeTimeRange!]!){
result: analysisEBPFProfilingResult(scheduleIdList: $scheduleIdList, timeRanges: $timeRanges) {
query ($scheduleIdList: [ID!]!, $timeRanges: [EBPFProfilingAnalyzeTimeRange!]!, $aggregateType: EBPFProfilingAnalyzeAggregateType){
result: analysisEBPFProfilingResult(scheduleIdList: $scheduleIdList, timeRanges: $timeRanges, aggregateType: $aggregateType) {
tip
trees {
elements {
Expand Down
13 changes: 12 additions & 1 deletion internal/commands/profiling/ebpf/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/urfave/cli/v2"

"github.com/apache/skywalking-cli/internal/flags"
"github.com/apache/skywalking-cli/internal/model/ebpf"
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/graphql/profiling"
Expand Down Expand Up @@ -53,6 +54,15 @@ $ swctl profiling ebpf analysis --schedule-id=abc --time-ranges=1648020042869-16
Name: "time-ranges",
Usage: "need to analyze time ranges in the segment: start-end,start-end",
},
&cli.GenericFlag{
Name: "aggregate",
Usage: "the aggregate type for the profiling data anlysis",
Value: &ebpf.ProfilingAnalyzeAggregateTypeEnumValue{
Enum: api.AllEBPFProfilingAnalyzeAggregateType,
Default: api.EBPFProfilingAnalyzeAggregateTypeCount,
Selected: api.EBPFProfilingAnalyzeAggregateTypeCount,
},
},
},
),
Action: func(ctx *cli.Context) error {
Expand All @@ -77,7 +87,8 @@ $ swctl profiling ebpf analysis --schedule-id=abc --time-ranges=1648020042869-16
}
}

analyzation, err := profiling.AnalysisEBPFProfilingResult(ctx, scheduleIDList, timeRanges)
aggregateType := ctx.Generic("aggregate").(*ebpf.ProfilingAnalyzeAggregateTypeEnumValue).Selected
analyzation, err := profiling.AnalysisEBPFProfilingResult(ctx, scheduleIDList, timeRanges, aggregateType)
if err != nil {
return err
}
Expand Down
49 changes: 49 additions & 0 deletions internal/model/ebpf/profilingAnalyzeAggregateType.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package ebpf

import (
"fmt"
"strings"

api "skywalking.apache.org/repo/goapi/query"
)

type ProfilingAnalyzeAggregateTypeEnumValue struct {
Enum []api.EBPFProfilingAnalyzeAggregateType
Default api.EBPFProfilingAnalyzeAggregateType
Selected api.EBPFProfilingAnalyzeAggregateType
}

func (e *ProfilingAnalyzeAggregateTypeEnumValue) Set(value string) error {
for _, enum := range e.Enum {
if strings.EqualFold(enum.String(), value) {
e.Selected = enum
return nil
}
}
orders := make([]string, len(api.AllEBPFProfilingAnalyzeAggregateType))
for i, order := range api.AllEBPFProfilingAnalyzeAggregateType {
orders[i] = order.String()
}
return fmt.Errorf("allowed analysis aggregate type are %s", strings.Join(orders, ", "))
}

func (e *ProfilingAnalyzeAggregateTypeEnumValue) String() string {
return e.Selected.String()
}
3 changes: 2 additions & 1 deletion pkg/graphql/profiling/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ func QueryEBPFProfilingScheduleList(ctx *cli.Context, taskID string) ([]*api.EBP
}

func AnalysisEBPFProfilingResult(ctx *cli.Context, scheduleIDList []string,
timeRanges []*api.EBPFProfilingAnalyzeTimeRange) (*api.EBPFProfilingAnalyzation, error) {
timeRanges []*api.EBPFProfilingAnalyzeTimeRange, aggregateType api.EBPFProfilingAnalyzeAggregateType) (*api.EBPFProfilingAnalyzation, error) {
var response map[string]*api.EBPFProfilingAnalyzation

request := graphql.NewRequest(assets.Read("graphqls/profiling/ebpf/AnalysisEBPFProfilingResult.graphql"))
request.Var("scheduleIdList", scheduleIDList)
request.Var("timeRanges", timeRanges)
request.Var("aggregateType", aggregateType)

err := client.ExecuteQuery(ctx, request, &response)

Expand Down