MCPcopy
hub / github.com/grafana/tempo / Run

Method Run

cmd/tempo-cli/cmd-query-trace-id.go:21–45  ·  view source on GitHub ↗
(_ *globalOptions)

Source from the content-addressed store, hash-verified

19}
20
21func (cmd *queryTraceIDCmd) Run(_ *globalOptions) error {
22 client := httpclient.New(cmd.APIEndpoint, cmd.OrgID)
23 applyHeaders(client, cmd.Headers)
24 // util.QueryTrace will only add orgID header if len(orgID) > 0
25
26 // use v1 API if specified, we default to v2
27 if cmd.V1 {
28 trace, err := client.QueryTrace(cmd.TraceID)
29 if err != nil {
30 return err
31 }
32 return printTrace(trace)
33 }
34
35 traceResp, err := client.QueryTraceV2(cmd.TraceID)
36 if err != nil {
37 return err
38 }
39 if traceResp.Message != "" {
40 // print message and status to stderr if there is one.
41 // allows users to get a clean trace on the stdout, and pipe it to a file or another commands.
42 _, _ = fmt.Fprintf(os.Stderr, "status: %s , message: %s\n", traceResp.Status, traceResp.Message)
43 }
44 return printTrace(traceResp.Trace)
45}
46
47func printTrace(trace *tempopb.Trace) error {
48 // tracebyid endpoints are protobuf, we are using 'gogo/protobuf/jsonpb' to marshal the

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
applyHeadersFunction · 0.85
printTraceFunction · 0.85
QueryTraceV2Method · 0.80
QueryTraceMethod · 0.65

Tested by

no test coverage detected