|
15 | 15 | #include <common/memleak.h> |
16 | 16 | #include <common/plugin.h> |
17 | 17 | #include <common/route.h> |
| 18 | +#include <common/trace.h> |
18 | 19 | #include <errno.h> |
19 | 20 | #include <plugins/libplugin.h> |
20 | 21 | #include <stdio.h> |
@@ -1058,7 +1059,14 @@ static void handle_rpc_reply(struct plugin *plugin, const jsmntok_t *toks) |
1058 | 1059 | cmd_freed = false; |
1059 | 1060 | tal_add_destructor2(out->cmd, destroy_cmd_mark_freed, &cmd_freed); |
1060 | 1061 |
|
| 1062 | + trace_span_resume(out); |
1061 | 1063 | contenttok = json_get_member(buf, toks, "error"); |
| 1064 | + |
| 1065 | + /* Annotate the JSON-RPC span whether it succeeded or failed, |
| 1066 | + * and then emit it. */ |
| 1067 | + trace_span_tag(out, "error", contenttok ? "true" : "false"); |
| 1068 | + trace_span_end(out); |
| 1069 | + |
1062 | 1070 | if (contenttok) { |
1063 | 1071 | if (out->errcb) |
1064 | 1072 | res = out->errcb(out->cmd, out->method, buf, contenttok, out->arg); |
@@ -1096,6 +1104,14 @@ send_outreq(const struct out_req *req) |
1096 | 1104 | json_object_end(req->js); |
1097 | 1105 | json_stream_close(req->js, req->cmd); |
1098 | 1106 |
|
| 1107 | + /* We are about to hand control over to the RPC, so suspend |
| 1108 | + * the current span. It'll be resumed as soon as we have a |
| 1109 | + * result to pass to either the error or the success |
| 1110 | + * callback. */ |
| 1111 | + trace_span_start("jsonrpc", req); |
| 1112 | + trace_span_tag(req, "id", req->id); |
| 1113 | + trace_span_suspend(req); |
| 1114 | + |
1099 | 1115 | ld_rpc_send(req->cmd->plugin, req->js); |
1100 | 1116 | notleak_with_children(req->cmd); |
1101 | 1117 | return &pending; |
|
0 commit comments