Repository navigation
Replies: 1 comment 1 reply
|
On the tool side I'd split |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation
I'd like to contribute an optional metrics extension for self-hosted DeerFlow deployments, so operators can scrape aggregate task, model-call and tool-call metrics into their existing Prometheus setup.
DeerFlow already integrates with LangSmith, Langfuse and Monocle for tracing. This proposal would complement those integrations with a direct Prometheus scrape surface; it does not assume tracing platforms cannot provide aggregation or alerting.
The task/tool monitoring request in #4357 is related, although this would address only the aggregate metrics portion. I also checked Discussion #2699: that work focuses on local diagnostics and execution timelines, while this proposal concerns deployment-level operational metrics.
The backend TODO also lists metrics and monitoring. More concretely, Discussion #6383 led to merged PR #6430, which adds synchronous/asynchronous tool outcome and elapsed-time statistics to the extension example. That provides an observation pattern to build on. Its
returned / raised / cancelledcategories describe control flow; this proposal would additionally distinguish reported tool errors. These references provide context, not prior approval of this exporter design.Proposed first version
Following the extension-first guidance, I propose a separately installable
deerflow-extension-prometheuspackage using the public extension API:TaskLifecycleContributor.MODEL_PHYSICAL, duration, outcome, bounded error categories and input/output tokens when usage is available.TOOL_VISIBLE, duration and reported outcomes, with interruption and cancellation distinguished from errors./metricslistener managed byExtensionService, proposed default127.0.0.1:9464, with optional bearer-token protection. No default Compose port publishing or changes to Gateway authentication.The intended implementation needs no host-core changes. If a contract gap emerges, I would bring it back for discussion. Package location (
examples/versus a separate community repository) and metric names remain open.Why a separate listener? Contributed Gateway routes inherit host authentication. The current PAT policy is default-deny outside explicitly allowed routes, and PAT credentials do not carry administrator capability (#5041). An ordinary PAT therefore cannot simply be used to scrape the proposed deployment-wide metrics route. A dedicated listener with its own optional bearer token would avoid changing host authentication for v1; this remains a deployment choice for maintainer feedback.
Candidate v1 metrics
Names and labels below are proposed for review, not a frozen API. Histograms would also expose the standard bucket/count/sum series.
deerflow_tasks_started_totalkind,agentdeerflow_tasks_finished_totalkind,agent,outcomedeerflow_task_duration_secondskind,outcomedeerflow_tasks_activekinddeerflow_llm_requests_totalmodel,scope,outcome,error_classdeerflow_llm_request_duration_secondsmodel,scopedeerflow_llm_tokens_totalmodel,scope,typedeerflow_tool_calls_totaltool,scope,outcomedeerflow_tool_call_duration_secondstool,scopedeerflow_metrics_label_overflow_totallabelkind/scopedistinguish lead and subagent work; tokentypeis limited to input/output in v1. Outcomes and error classes use fixed vocabularies. Agent/tool/model names are bounded; suppressed agent/tool names would use a constant label value. Request and tool counters refer to attempts at the observation boundaries described below.Measurement and operational boundaries
MODEL_PHYSICALsees retries that re-enter the middleware, but may not see retries inside a provider SDK. These would be middleware-observed attempts, not a guarantee of counting every HTTP request or every 429. The current model factory setsmax_retries=0whenrequest_admissionis configured and the model class exposes that field. This reduces hidden SDK retries on that path; it does not guarantee visibility into retries in other layers. Other configurations may undercount actual 429 responses, and observed duration can include SDK retry/backoff time. The extension would not change retry policy to improve measurement.Commandresults would need explicit handling of any relevant errorToolMessagethey carry.Scope and validation
V1 would exclude system-model/compaction metrics, HTTP/sandbox/queue instrumentation, dashboards, per-user/tenant metrics, TTFT, OTLP export and Helm integration. System-model and compaction metrics could be small follow-ups. Multi-worker support would need a separate design for exporter ownership/failover, dead-worker cleanup and file I/O.
Tests would cover sync/async hooks, result/exception preservation, lifecycle asymmetry, labels, authentication and listener cleanup, plus host integration using fake models/tools. Extension dependencies would be installed explicitly in the test environment; the existing wheel/package check does not replace running those tests. Real-run validation and any untested cases would be reported accurately in a later PR.
Feedback requested before implementation
examples/package or a separately maintained community package?prometheus-clientas an extension-only dependency appropriate, or would you prefer an OTel Metrics approach?I will wait for directional feedback before implementing v1 and open a linked tracking issue if that would help.
All reactions