diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index ed78d7681..17254703f 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -2250,6 +2252,18 @@ static struct command_result *payment_finished(struct payment *p) return command_finished(cmd, ret); } +const char * const payment_step_str[] = +{ + [PAYMENT_STEP_INITIALIZED] = "PAYMENT_STEP_INITIALIZED", + [PAYMENT_STEP_GOT_ROUTE] = "PAYMENT_STEP_GOT_ROUTE", + [PAYMENT_STEP_RETRY_GETROUTE] = "PAYMENT_STEP_RETRY_GETROUTE", + [PAYMENT_STEP_ONION_PAYLOAD] = "PAYMENT_STEP_ONION_PAYLOAD", + [PAYMENT_STEP_SPLIT] = "PAYMENT_STEP_SPLIT", + [PAYMENT_STEP_RETRY] = "PAYMENT_STEP_RETRY", + [PAYMENT_STEP_FAILED] = "PAYMENT_STEP_FAILED", + [PAYMENT_STEP_SUCCESS] = "PAYMENT_STEP_SUCCESS", +}; + void payment_set_step(struct payment *p, enum payment_step newstep) { p->current_modifier = -1; @@ -2264,12 +2278,17 @@ struct command_result *payment_continue(struct payment *p) { struct payment_modifier *mod; void *moddata; + + trace_span_start("payment_continue", p); /* If we are in the middle of calling the modifiers, continue calling * them, otherwise we can continue with the payment state-machine. */ p->current_modifier++; mod = p->modifiers[p->current_modifier]; if (mod != NULL) { + char *str = tal_fmt(tmpctx, "%d", p->current_modifier); + trace_span_tag(p, "modifier", str); + trace_span_end(p); /* There is another modifier, so call it. */ moddata = p->modifier_data[p->current_modifier]; return mod->post_step_cb(moddata, p); @@ -2277,6 +2296,8 @@ struct command_result *payment_continue(struct payment *p) /* There are no more modifiers, so reset the call chain and * proceed to the next state. */ p->current_modifier = -1; + trace_span_tag(p, "step", payment_step_str[p->step]); + trace_span_end(p); switch (p->step) { case PAYMENT_STEP_INITIALIZED: case PAYMENT_STEP_RETRY_GETROUTE: @@ -2299,6 +2320,7 @@ struct command_result *payment_continue(struct payment *p) return command_still_pending(payment_cmd(p)); } } + trace_span_end(p); /* We should never get here, it'd mean one of the state machine called * `payment_continue` after the final state. */ abort(); diff --git a/plugins/test/run-route-calc.c b/plugins/test/run-route-calc.c index b21730c31..98c3e61f3 100644 --- a/plugins/test/run-route-calc.c +++ b/plugins/test/run-route-calc.c @@ -314,6 +314,15 @@ void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for trace_span_end */ +void trace_span_end(const void *key UNNEEDED) +{ fprintf(stderr, "trace_span_end called!\n"); abort(); } +/* Generated stub for trace_span_start */ +void trace_span_start(const char *name UNNEEDED, const void *key UNNEEDED) +{ fprintf(stderr, "trace_span_start called!\n"); abort(); } +/* Generated stub for trace_span_tag */ +void trace_span_tag(const void *key UNNEEDED, const char *name UNNEEDED, const char *value UNNEEDED) +{ fprintf(stderr, "trace_span_tag called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ #ifndef SUPERVERBOSE diff --git a/plugins/test/run-route-overlong.c b/plugins/test/run-route-overlong.c index a324dc1c6..5fc606f5e 100644 --- a/plugins/test/run-route-overlong.c +++ b/plugins/test/run-route-overlong.c @@ -311,6 +311,15 @@ void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED) /* Generated stub for towire_channel_id */ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "towire_channel_id called!\n"); abort(); } +/* Generated stub for trace_span_end */ +void trace_span_end(const void *key UNNEEDED) +{ fprintf(stderr, "trace_span_end called!\n"); abort(); } +/* Generated stub for trace_span_start */ +void trace_span_start(const char *name UNNEEDED, const void *key UNNEEDED) +{ fprintf(stderr, "trace_span_start called!\n"); abort(); } +/* Generated stub for trace_span_tag */ +void trace_span_tag(const void *key UNNEEDED, const char *name UNNEEDED, const char *value UNNEEDED) +{ fprintf(stderr, "trace_span_tag called!\n"); abort(); } /* AUTOGENERATED MOCKS END */ #ifndef SUPERVERBOSE