Repository navigation
feat: metrics block (OTLP / Prometheus), Phoenix and OTLP tracing, init full mode with worker - #76
Merged
Merged
Conversation
- Added Phoenix observability configuration options in .env.example and agent.py. - Updated tests to validate Phoenix observability settings and ensure compatibility with existing configurations. - Modified setup middleware to bind Phoenix observability when enabled. - Adjusted production template defaults to include memory storage and JWT authentication. - Enhanced documentation for observability features, including Phoenix setup instructions. - Refactored tests to ensure proper handling of storage presets and cache store configurations.
- Introduced metrics configuration in the main application setup, allowing for telemetry data collection. - Updated the middleware setup to include metrics handling and observability features. - Added tests to validate the integration of metrics and observability configurations. - Adjusted route protection to account for public metrics endpoints. - Refactored telemetry flushing to ensure it does not block other operations. - Corrected metric duration recording to align with new naming conventions. - Implemented validation for metrics configuration to ensure proper setup.
… only to event publishers - Updated MonitoringMiddleware to ensure task failures are logged as ERROR and counted, but not published as events. - Modified event publishing to restrict to event publishers only, using the `only="events"` argument. - Adjusted test cases to verify the correct behavior of event publishing and logging, ensuring failures are not published. - Added a fixture to track the `only` argument in publish_event calls for testing purposes.
…nter and InjectQ for binding
- Updated the git source for the "10xgraph" package to a new commit. - Added new optional dependencies under the "metrics" extra, including: - opentelemetry-api - opentelemetry-exporter-otlp-proto-http - opentelemetry-exporter-prometheus - opentelemetry-instrumentation-fastapi - opentelemetry-sdk - prometheus-client - Updated version numbers for several opentelemetry packages to 1.45.2 and 0.66b2. - Added "prometheus-client" as a new package dependency. - Updated the "provides-extras" list to include "metrics".
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a
metricsblock to10xgraph.jsonfor request, task and LLM metrics. Metrics are kept separate from AI tracing: HTTP spans never reach an AI tracing backend. It also passes the new core Phoenix and OTLP trace backends through to the API, and gives10xgraph inita full setup mode that can scaffold a background worker.What changed
Metrics (
core/config/metrics.py, new)metricsblock in10xgraph.json, withexportset to"otlp"(push) or"prometheus"(scrape):exportis required when enabled, and the path cannot be/.worker_port./ping, and skips the auth guard, the Host check and the rate limit. Startup fails if another route matches the scrape path. Scrape requests are left out of the HTTP metrics.OTEL_ENABLEDpath is on. FastAPI's own built-in telemetry is turned off on FastAPI versions that have it, so request spans never reach Phoenix, LangSmith, Logfire or OTLP.observability.otlp.use_metrics_endpointsends AI traces to the same OTLP endpoint as metrics. It warns if that endpoint is a Prometheus OTLP URL, since Prometheus accepts metrics only.10xgraph-api[metrics].AI tracing
observabilityblock now also acceptsphoenixandotlp, using the core 1.0 helpers. Secrets come from env vars (PHOENIX_API_KEY,OTEL_EXPORTER_OTLP_HEADERS).Jobs
MonitoringMiddlewarenow publishes task events to event publishers only, usingpublish_event(..., only="events"). Before, AI tracing backends received them too and showed each task as a graph run.tenxgraph.task.duration_mstotenxgraph.task.duration.10xgraph init--mode quick|full. The old--templatestays as an alias.--storage(memory,sqlite,postgres,postgres-memory),--evals/--no-evals,--tests/--no-tests,--ag-ui/--no-ag-ui,--otel/--no-otel, and--worker(none,redis,rabbitmq,kafka).--workerscaffoldsworker/tasks.pywith an example task..env.examplecovers Phoenix and metrics.init.pyis split intoinit_context.pyandinit_prompts.py.Config editor
metricsandobservabilityblocks, with schema and validation.Fix
/health/readydo, throughreadiness_targets. Before, it looked it up by a string key the graph never binds.Example
examples/observability/: a local stack (OpenTelemetry Collector, Prometheus, Grafana with a 10xGraph dashboard, Redis) bound to 127.0.0.1. It is for local use only.Behavior changes to note
tenxgraph.task.duration_msmetric is nowtenxgraph.task.duration.OTEL_ENABLED, the API produces no HTTP spans. FastAPI's built-in telemetry is off.inittemplate now defaults to memory storage and JWT.Dependencies
uv.lockpins coremainat0b65e3b, which includes PR #341 (Phoenix and OTLP tracing,PublisherKind,publish_event(only=...)).pyproject.tomlfloor is still10xgraph>=1.0.0rc4.publish_event(only=...)exists only on coremain, so the floor has to move to the next core rc at release.Tests
test_metrics.py,test_metrics_real_packages.py,test_init_full.py,test_init_worker.py,test_worker.py, and config editor tests.uv run pytest -m "not integration"against the updated lock: 3208 passed, 14 skipped.