Create StreamingTraceManager once#107
Conversation
0de5e6b to
ee46324
Compare
| main_server = uvicorn.Server(uvicorn.Config(main_app, port=port, **shared_kwargs)) | ||
| otlp_http_server = uvicorn.Server(uvicorn.Config(otlp_app, port=otlp_http_port, **shared_kwargs)) |
There was a problem hiding this comment.
Will this break hot reload functionality of --dev?
There was a problem hiding this comment.
Good catch.
I checked this more closely and the combined serve --dev path wasn't actually getting uvicorn hot reload before this change either: it runs uvicorn.Server(...).serve() directly, and the reload=True / reload_dirs=... config there doesn't start uvicorn's reload supervisor. So this PR doesn't introduce a new regression, but it did make the mismatch more visible. Could you confirm?
I've cleaned that up in this branch by removing the dead reload plumbing and keeping the startup wiring explicit around the shared StreamingTraceManager. If we want real hot reload for the multi-surface dev server, I'd prefer to handle that as a follow-up since it likely needs a different startup shape. Make sense?
src/agentevals/api/app.py
Outdated
| *, | ||
| trace_manager: StreamingTraceManager | None = None, | ||
| enable_streaming: bool = False, | ||
| manage_trace_manager_lifecycle: bool = True, |
There was a problem hiding this comment.
Nothing in this PR sets this to False, and the guard already makes this a no-op when there's no manager. Do you have a use-case for this in mind?
There was a problem hiding this comment.
Removed the unused lifecycle flag
Summary
Fixes Issue #99 by creating
StreamingTraceManageronce during startup and injecting it explicitly into the live server components instead of discovering it through module-level app state.create_app(...)andcreate_otlp_app(...)factories so the main API app and OTLP HTTP app can receive the shared manager directly.cli._run_servers()to create a singleStreamingTraceManagerand pass it to the main API app, OTLP HTTP app, and OTLP gRPC server.require_trace_manager_from_app(...).Why
app.state.trace_manager.