Repository navigation
add operationMetrics to core, add registry to trueforge server - #1075
ramantehlan wants to merge 22 commits into
Conversation
🦋 Changeset detectedLatest commit: b77bf03 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
UNPROCESSED_RETRY_STATUSES and MAYBE_PROCESSED_RETRY_STATUSES choose which responses replay. Tests check request outcome, status class, and retry counts. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
These files stay on disk for local runs and should not ship with the branch. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
OpenAPI generation creates the same registry as the server, and turn and schedule wiring always receives the recorder. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
The collectDefaultMetrics switch had no caller. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
The metrics cases added here are dropped. The rest of the file stays. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
The Vercel stream test is back to its previous coverage. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
The retry label is the status that was replayed. Status class and blocked-request checks only need the error or the single wrap under it. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
…am errors. Both series were classifying the same status ranges in separate helpers. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
…ror. Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0d3733d. Configure here.
Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
Signed-off-by: Raman Tehlan <ramantehlan@gmail.com>
chiragjn
left a comment
There was a problem hiding this comment.
It is fine for trueforge-core to be prometheus metrics aware
It can take prom registry at server init time
and internally it can keep emitting metrics with util functions wherever needed
https://github.com/truefoundry/tfy-llm-gateway/blob/main/src/metrics/helpers.ts#L168

Summary
Closes #
Changes
How was this tested?
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,python/trueforge_sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Medium Risk
Broad instrumentation touches turn persistence, outbound HTTP, LLM/MCP paths, and the metrics scrape endpoint; behavior is mostly additive when metrics are omitted, but mis-wiring could affect hot paths or scrape reliability.
Overview
Adds an optional
OperationMetricshook in trueforge-core so hosts can record harness behavior without importing a metrics client, and wires a Prometheus implementation in trueforge on the existingGET /metricsregistry.Instrumentation spans outbound HTTP (generic/model/MCP pools, retries, blocked URLs), LLM streams (duration, TTFT, stream errors by provider), MCP connect/ops/disconnect/session retry, tool calls (outcome + duration by server class), harness limits (iteration, large tool responses, context compaction, MCP response size), active threads/turns, turn lifetime and persist failures, turn timeouts/SSE disconnects, Parallel web search/extract, ServiceFoundry calls, and Postgres query duration.
ITurnResourceResolverand turn construction passoperationMetricsthrough orchestrator, threads, builtins, sandbox, and RemoteMCP.Server wiring: shared
httpMetrics.registry,createOperationMetrics, outbound fetch metrics at boot, Postgres Kysely logging,ActiveTurnRegistrygauges, turns/schedules APIs;GET /metricsalso appends OpenTelemetry text for Daytona and Redis SDK meters. Core exports types/helpers (observeMcpOperation,elapsedSeconds,OUTBOUND_URL_BLOCKED).Reviewed by Cursor Bugbot for commit b77bf03. Bugbot is set up for automated code reviews on this repo. Configure here.