feat(agent-proxy): report proxied service usage#322
Conversation
|
💬 Discussion in Slack: #pr-review-cli-322-feat-agent-proxy-report-proxied-service-usage Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| packages/agentproxy/proxy.go | Adds synchronized usage tracking and periodic reporting, but reporting can block cache refreshes and pending usage is not flushed during shutdown. |
| packages/api/agent_proxy.go | Adds the usage-report request model and API helper with standard error handling. |
Comments Outside Diff (1)
-
packages/agentproxy/proxy.go, line 174 (link)Pending Usage Is Lost On Shutdown
The usage poller has no stop or final-flush path, while shutdown only stops the lease refresh loop. Any usage recorded after the last tick is therefore discarded when the process exits, so a service used shortly before a normal restart may never have its last-used timestamp reported.
Reviews (1): Last reviewed commit: "feat(agent-proxy): report proxied servic..." | Re-trigger Greptile
8bcafc5 to
338722f
Compare
4f496cb to
8e54f1c
Compare
8e54f1c to
b05835f
Compare
…ghts-on-dashboard
…nfig #319) Resolve packages/agentproxy/proxy.go, keeping both sides: - local coupled mode (New/Serve/Shutdown, serviceResolver, control-plane fence, graceful pollLoop stop) from this branch. - proxied-service usage reporting (recordUsage/flushUsage) from #322. Also flush usage on shutdown: `run` is frequently shorter than one poll interval, so the poll-tick flush alone would never report a short session's usage. The daemon (`start`) path still flushes each tick.
Description 📣
Adds best-effort usage reporting to the agent proxy, which powers a "last used" indicator on proxied services in the dashboard. Until now the proxy only logged per-request activity to its local stream, so the platform had no signal of whether a proxied service was actually being used.
When the proxy brokers a request for a proxied service, it records the service's ID and the time. Once per poll tick it reports the latest time per service via
POST /v1/proxied-services/:serviceId/report-usage, authenticating with the proxy's own machine identity (never the agent's — the agent token lives in the untrusted execution environment, so letting it report would let a compromised agent forge usage).now()and only advances monotonically), so a longer--poll-intervaldoesn't skew the timestamp.Companion PR: Infisical/infisical#7359
Type ✨
Tests 🛠️
# Here's some code block to paste some code snippets