Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/untraced-event-poll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@executor-js/sdk": patch
---

Self-host and local check for due event deliveries every two seconds. That
check no longer records traces when it finds nothing to deliver; each delivery
attempt and each subscription it expires is still traced. An idle self-host
instance no longer fills the bundled Motel store with polling spans.
11 changes: 11 additions & 0 deletions .changeset/untraced-idle-polls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@executor-js/sdk": patch
"@executor-js/hosted-server": patch
---

The scheduler's check for due runs, every second on self-host and local, and
self-host's check for queued provisioning jobs, every second, no longer record
traces when they find nothing to do. Each scheduled operation a check finds is
still traced, in its own `schedule.dispatch` trace, and so is each provisioning
job. An idle self-host instance no longer fills the bundled Motel store with
polling spans.
2 changes: 2 additions & 0 deletions apps/hosted/server/src/implementation/provisioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ export const drainProvisioning = (services: ProvisioningServices) =>
Effect.flatMap(
Schema.decodeUnknownEffect(Schema.Array(Schema.Struct({ id: Schema.String }))),
),
// Self-host polls every second. The poll records nothing; the jobs it finds are traced.
Effect.withTracerEnabled(false),
);
for (const job of jobs)
yield* provision(job.id, services).pipe(
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/src/implementation/event-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const deliverEvents = (executor: Executor) =>
yield* Effect.flatten(ScheduleHostReady);
yield* executor.events.deliver({ maxDeliveries: batch }).pipe(
Effect.repeat({ while: (more) => more }),
Effect.withSpan("events.dispatch"),
// A pass runs every two seconds; one that finds nothing to deliver records nothing.
Effect.withTracerEnabled(false),
Effect.catch(() => Effect.logError("Event delivery failed")),
Effect.repeat(Schedule.spaced("2 seconds")),
);
Expand Down
12 changes: 10 additions & 2 deletions packages/sdk/src/implementation/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,11 @@ export const makeEvents = (input: {
limit: 100,
}),
);
for (const row of lapsed) yield* stopWith(EventSubscriptionId.make(row.id), "expired");
// A host may poll without tracing; the work a pass finds is traced all the same.
for (const row of lapsed)
yield* stopWith(EventSubscriptionId.make(row.id), "expired").pipe(
Effect.withTracerEnabled(true),
);
const due = yield* query(() =>
db.findMany("eventDeliveries", {
where: (b) =>
Expand All @@ -825,7 +829,11 @@ export const makeEvents = (input: {
due,
(row) =>
claim(row.id).pipe(
Effect.flatMap((claimed) => (claimed === null ? Effect.void : attempt(claimed))),
Effect.flatMap((claimed) =>
claimed === null
? Effect.void
: attempt(claimed).pipe(Effect.withTracerEnabled(true)),
),
Effect.catch(() => Effect.logWarning("Event delivery attempt failed")),
),
{ concurrency: 8, discard: true },
Expand Down
13 changes: 10 additions & 3 deletions packages/sdk/src/implementation/schedule-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ export const startScheduleWorker = (
runner: config.runner,
maxCandidates: config.concurrency,
authorize,
execute: (operation) => pool.withPermitsIfAvailable(1)(operation).pipe(Effect.asVoid),
// Each operation a pass finds is one trace, rooted in a dispatch as a Cloud
// coordinator's pass is.
execute: (operation) =>
pool
.withPermitsIfAvailable(1)(
operation.pipe(Effect.withSpan("schedule.dispatch"), Effect.withTracerEnabled(true)),
)
.pipe(Effect.asVoid),
})
.pipe(
// Each pass is one trace, as a Cloud coordinator's dispatch is.
Effect.withSpan("schedule.dispatch"),
// A pass runs every second; one that finds nothing to run records nothing.
Effect.withTracerEnabled(false),
Effect.catch(() => Effect.logError("Scheduled dispatch failed")),
Effect.forkIn(scope),
Effect.asVoid,
Expand Down