feat(natsrpc): propagate trace context across NATS and into task runs

This commit is contained in:
sam committed 2026-10-25 23:03:55 +11:00
1 parent 4a889991bd
commit 0880e6a01c
37 files changed
+245 -117

No files matched your search

+3 -4
View File
@@ -108,18 +108,17 @@ func actionErrorFor(kind string, err error) error {
return err
}
// Register serves identity-scoped task actions over NATS. Handlers use
// context.Background().
// Register serves identity-scoped task actions over NATS.
func Register(nc *nats.Conn, service taskactions.Service, log *slog.Logger) (func(), error) {
return natsrpc.RegisterAll(nc, []natsrpc.Registration{{
Subject: actionSubject,
Handler: func(msg *nats.Msg) {
Handler: func(ctx context.Context, msg *nats.Msg) {
var req actionRequest
if err := json.Unmarshal(msg.Data, &req); err != nil {
natsrpc.Respond(msg, log, "taskactions", actionResponse{Envelope: natsrpc.NewEnvelope(err)})
return
}
err := service.Apply(context.Background(), req.Identity, req.Actor.actor(), req.TaskID, req.Action, taskactions.ActionPayload{
err := service.Apply(ctx, req.Identity, req.Actor.actor(), req.TaskID, req.Action, taskactions.ActionPayload{
Instructions: req.Instructions,
Findings: req.Findings,
RetryMode: req.RetryMode,
@@ -20,7 +20,7 @@ func NewService(
mergePR func(context.Context, string, string, int) error,
removeLogs func(int64) error,
removeWorktree func(*taskactions.Task) error,
publish func(events.Event),
publish func(context.Context, events.Event),
warn func(string, ...any),
) taskactions.Service {
return taskactions.Service{