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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Release Notes.
* Add the sub-command `alarm autocomplete-keys` and `alarm auto-complete-values` for alarm query API by @mrproliu in https://github.com/apache/skywalking-cli/pull/210
* Adapt the alarm message query API by @mrproliu in https://github.com/apache/skywalking-cli/pull/210
* Add the owner field in the `metrics exec` query API by @mrproliu in https://github.com/apache/skywalking-cli/pull/210
* Add the `trace-v2 list` command for adapt the new trace query API by @mrproliu in https://github.com/apache/skywalking-cli/pull/225
* Add the duration field in the `trace list` command by @mrproliu in https://github.com/apache/skywalking-cli/pull/225
* Remove the oldest `queryTraceFromColdStage` query call in the `trace list` command by @mrproliu in https://github.com/apache/skywalking-cli/pull/225

### Bug Fixes

Expand Down
4 changes: 2 additions & 2 deletions assets/graphqls/trace/Trace.graphql
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 ($traceId: ID!) {
result: queryTrace(traceId: $traceId) {
query ($traceId: ID!, $duration: Duration) {
result: queryTrace(traceId: $traceId, duration: $duration) {
spans {
traceId
segmentId
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 ($traceId: ID!, $duration: Duration!) {
result: queryTraceFromColdStage(traceId: $traceId, duration: $duration) {
query ($traceId: ID!) {
result: queryTrace(traceId: $traceId) {
spans {
traceId
segmentId
Expand Down
71 changes: 71 additions & 0 deletions assets/graphqls/tracev2/Traces.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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.

query ($condition: TraceQueryCondition){
result: queryTraces(condition: $condition){
traces {
spans {
traceId
segmentId
spanId
parentSpanId
refs {
traceId
parentSegmentId
parentSpanId
type
}
serviceCode
serviceInstanceName
startTime
endTime
endpointName
type
peer
component
isError
layer
tags {
key value
}
logs {
time data {
key value
}
}
attachedEvents {
startTime {
seconds nanos
}
event
endTime {
seconds nanos
}
tags {
key value
}
summary {
key value
}
}
}
}
retrievedTimeRange {
startTime endTime
}
}
}
2 changes: 2 additions & 0 deletions cmd/swctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/apache/skywalking-cli/internal/commands/records"
"github.com/apache/skywalking-cli/internal/commands/service"
"github.com/apache/skywalking-cli/internal/commands/trace"
"github.com/apache/skywalking-cli/internal/commands/tracev2"
intutil "github.com/apache/skywalking-cli/internal/util"
"github.com/apache/skywalking-cli/pkg/logger"
"github.com/apache/skywalking-cli/pkg/util"
Expand Down Expand Up @@ -99,6 +100,7 @@ services, service instances, etc.`
service.Command,
metrics.Command,
trace.Command,
tracev2.Command,
healthcheck.Command,
dashboard.Command,
install.Command,
Expand Down
4 changes: 2 additions & 2 deletions dist/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ The text of each license is also included at licenses/license-[project].txt.
github.com/spf13/afero v1.2.2 Apache-2.0
gomodules.xyz/jsonpatch/v2 v2.5.0 Apache-2.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 Apache-2.0
google.golang.org/grpc v1.72.0 Apache-2.0
google.golang.org/grpc v1.73.0 Apache-2.0
gopkg.in/ini.v1 v1.51.0 Apache-2.0
gopkg.in/yaml.v2 v2.4.0 Apache-2.0
k8s.io/api v0.33.1 Apache-2.0
Expand All @@ -213,7 +213,7 @@ The text of each license is also included at licenses/license-[project].txt.
sigs.k8s.io/controller-runtime v0.20.4 Apache-2.0
sigs.k8s.io/randfill v1.0.0 Apache-2.0
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 Apache-2.0
skywalking.apache.org/repo/goapi v0.0.0-20250516073621-c1d2fb980695 Apache-2.0
skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc Apache-2.0

========================================================================
Apache-2.0 and BSD-3-Clause licenses
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ require (
github.com/spf13/viper v1.7.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/text v0.25.0
google.golang.org/grpc v1.72.0
google.golang.org/grpc v1.73.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.33.1
sigs.k8s.io/controller-runtime v0.20.4
skywalking.apache.org/repo/goapi v0.0.0-20250516073621-c1d2fb980695
skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc
)

require (
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,16 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
Expand Down Expand Up @@ -487,8 +487,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2/go.
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down Expand Up @@ -543,5 +543,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.7.0 h1:qPeWmscJcXP0snki5IYF79Z8xrl8ETFxg
sigs.k8s.io/structured-merge-diff/v4 v4.7.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
skywalking.apache.org/repo/goapi v0.0.0-20250516073621-c1d2fb980695 h1:ED9fRO1rV5K3Kr5HQa1pQ87/xtXBmjYvT1EQfQ1VV3Y=
skywalking.apache.org/repo/goapi v0.0.0-20250516073621-c1d2fb980695/go.mod h1:rTNGn2QrS+p1i2OaIBxlwQ/VrDSDc7OwRk/iWV+mU0k=
skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc h1:HhlLDl0aOIgiIdJl9p0a7PHHdZbs9epKEnewB7AWdZs=
skywalking.apache.org/repo/goapi v0.0.0-20250918024206-7be91673cadc/go.mod h1:Vj9vINJYsTQASPsbQ1i81YgH8nFC/Xds4GjcXvmRYwM=
8 changes: 0 additions & 8 deletions internal/commands/trace/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ $ swctl trace ls --trace-id "321661b1-9a31-4e12-ad64-c8f6711f108d" --cold
traceID := ctx.String("trace-id")
tagStr := ctx.String("tags")

if coldStage && traceID != "" {
trace, err := trace.ColdTrace(ctx.Context, duration, traceID)
if err != nil {
return err
}
return display.Display(ctx.Context, &displayable.Displayable{Data: trace})
}

var tags []*api.SpanTag = nil
if tagStr != "" {
tagArr := strings.SplitSeq(tagStr, ",")
Expand Down
28 changes: 27 additions & 1 deletion internal/commands/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (

"github.com/urfave/cli/v2"

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

"github.com/apache/skywalking-cli/internal/commands/interceptor"
"github.com/apache/skywalking-cli/internal/flags"
"github.com/apache/skywalking-cli/internal/model"
"github.com/apache/skywalking-cli/pkg/display"
"github.com/apache/skywalking-cli/pkg/display/displayable"
"github.com/apache/skywalking-cli/pkg/graphql/trace"
Expand All @@ -39,12 +44,33 @@ with specified options, like service name, endpoint name, etc.
Examples:
1. Query the trace details (spans) of id "321661b1-9a31-4e12-ad64-c8f6711f108d":
$ swctl trace "321661b1-9a31-4e12-ad64-c8f6711f108d"`,
Flags: flags.Flags(flags.DurationFlags),
Action: func(ctx *cli.Context) error {
if ctx.NArg() == 0 {
return fmt.Errorf("command trace without sub command requires 1 trace id as argument")
}

trace, err := trace.Trace(ctx.Context, ctx.Args().First())
// if the user has set start or end, then we use the duration
var duration *api.Duration
start := ctx.String("start")
end := ctx.String("end")
if start != "" || end != "" {
if err := interceptor.DurationInterceptor(ctx); err != nil {
return err
}
step := ctx.Generic("step")
coldStage := ctx.Bool("cold")
start = ctx.String("start")
end = ctx.String("end")
duration = &api.Duration{
Start: start,
End: end,
Step: step.(*model.StepEnumValue).Selected,
ColdStage: &coldStage,
}
}

trace, err := trace.Trace(ctx.Context, duration, ctx.Args().First())
if err != nil {
return err
}
Expand Down
Loading
Loading