(_ *globalOptions)
| 19 | } |
| 20 | |
| 21 | func (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 | |
| 47 | func printTrace(trace *tempopb.Trace) error { |
| 48 | // tracebyid endpoints are protobuf, we are using 'gogo/protobuf/jsonpb' to marshal the |
nothing calls this directly
no test coverage detected