Skip to content

feat: compute metering — fire-and-forget usage logging for every job#102

Closed
pyramation wants to merge 1 commit into
feat/inline-node-executionfrom
feat/compute-metering
Closed

feat: compute metering — fire-and-forget usage logging for every job#102
pyramation wants to merge 1 commit into
feat/inline-node-executionfrom
feat/compute-metering

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Adds non-blocking compute metering so every job (inline FBP node or HTTP cloud function) writes timing and identity context to the billing tables without affecting throughput.

New module: job/worker/src/compute-meter.ts

logComputeUsage(pool, {
  jobId, taskIdentifier, databaseId, actorId, entityId,
  durationMs, status, error, payload, result,
  graphExecutionId, nodeName, dispatchType
})

Fires two async INSERTs (never awaited, errors swallowed):

  1. constructive_compute_public.platform_function_invocations — detailed per-invocation record
  2. constructive_usage_public.platform_usage_log_computes — billing record linked via invocation_id

Worker integration: Worker.doWork() captures process.hrtime.bigint() before execution, computes durationMs after, and calls logComputeUsage() on both the inline and HTTP paths.

Tests:

  • 10 new integration tests (compute-meter.test.ts) — verify both INSERTs, correct columns, invocation linking, error resilience, duration rounding
  • 6 updated inline-worker.test.ts tests — added graphCalls()/meterCalls() filters to separate graph-engine SQL from metering INSERTs

Link to Devin session: https://app.devin.ai/sessions/b2291a8e333e445aa125a2efd1996206
Requested by: @pyramation

Add compute-meter.ts with logComputeUsage() that INSERTs into both
platform_function_invocations and platform_usage_log_computes tables.
Wire timing into Worker.doWork for both inline FBP nodes and HTTP
cloud functions. All writes are async/non-blocking (fire-and-forget).

- 10 new integration tests for compute-meter module
- 6 updated inline-worker tests with metering verification
- Uses process.hrtime.bigint() for nanosecond-precision timing
- Links tables via shared invocation_id (UUID)
- Identity context: database_id, entity_id, actor_id per job
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown

Superseded — already merged into develop via #104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant