Skip to content

Commit 8471127

Browse files
feat(profilecli): Add --max-nodes flag to query profile command (#4433)
Add support for limiting the number of nodes returned in profile queries through the new --max-nodes flag. This matches the functionality available in buf curl but was missing from profilecli. Reference: grafana/pyroscope-squad#568 (comment) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent dd0e10a commit 8471127

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/profilecli/query.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ type queryProfileParams struct {
9494
*queryParams
9595
ProfileType string
9696
StacktraceSelector []string
97+
MaxNodes int64
9798
}
9899

99100
func addQueryProfileParams(queryCmd commander) *queryProfileParams {
100101
params := new(queryProfileParams)
101102
params.queryParams = addQueryParams(queryCmd)
102103
queryCmd.Flag("profile-type", "Profile type to query.").Default("process_cpu:cpu:nanoseconds:cpu:nanoseconds").StringVar(&params.ProfileType)
103104
queryCmd.Flag("stacktrace-selector", "Only query locations with those symbols. Provide multiple times starting with the root").StringsVar(&params.StacktraceSelector)
105+
queryCmd.Flag("max-nodes", "Maximum number of nodes to return in the profile").Int64Var(&params.MaxNodes)
104106
return params
105107
}
106108

@@ -118,6 +120,10 @@ func queryProfile(ctx context.Context, params *queryProfileParams, outputFlag st
118120
LabelSelector: params.Query,
119121
}
120122

123+
if params.MaxNodes > 0 {
124+
req.MaxNodes = &params.MaxNodes
125+
}
126+
121127
if len(params.StacktraceSelector) > 0 {
122128
locations := make([]*typesv1.Location, 0, len(params.StacktraceSelector))
123129
for _, cs := range params.StacktraceSelector {

0 commit comments

Comments
 (0)