Repository navigation
Expose FastAPI 0.162 telemetry settings in create_app #3917
zzbazzzbaz
started this conversation in
Ideas
Replies: 1 comment
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.
Problem
agentscope.app.create_appcreates the internalFastAPIapp without exposing FastAPI 0.162's newtelemetryparameter:FastAPI 0.162 enables native OpenTelemetry telemetry by default:
tracing=True,metrics=True,logs=True,operation_spans=True.When users follow the AgentScope tracing guide and register a global
TracerProvider+ OTLP exporter, FastAPI automatically exports an HTTP spanfor every request, for example:
GET /sessions/{session_id}/messagesGET /sessions/{session_id}/statusPOST /chat/fastapi.dependenciesfastapi.endpointfastapi.serializationThese non-agent spans go to the same backend. In Langfuse, they dominate the
trace list and make the agent traces much harder to read.
Why it is hard to work around
create_appconstructsFastAPI(...)internally and does not exposetelemetry.**kwargsrejects unknown arguments, sotelemetry=...cannot be forwarded.extra_middlewarescannot disable it:FastAPI.__call__checks/processes the telemetry flag before running the user middleware stack.fastapi.FastAPIor filtering spans in a customSpanExporter, neither of which is a supported API.Proposal
Expose a parameter on
create_app, for example:or a generic
fastapi_kwargs: dict[str, Any] | Noneforwarded toFastAPI(...).At minimum, document that FastAPI 0.162 native telemetry uses the global
TracerProvider, so users who only want AgentScope spans must disable orfilter it.
Related
I'd like to implement this if the team agrees with the API shape.
All reactions