Tracing | Rasa Documentation
Build your first agent in just a few minutes with Rasa Copilot.
On this page
Distributed tracing tracks requests as they flow through a distributed system (in this case: a Rasa assistant), sending data about the requests to a tracing backend which collects all trace data and enables inspecting it. Trace data helps you understand the flow of requests through both the components of a single service (Rasa itself), and across different distributed services, for example, your action server.
Supported Tracing Backends/Collectors
To trace requests in Rasa, you can either use Jaeger as a backend, or use the OTEL Collector (OpenTelemetry Collector). to collect traces and then send them to the backend of your choice. See Configuring a Tracing Backend or Collector for instructions.
Rasa Channels
Trace context sent along with requests using the W3C Trace Context Specification via the REST channel is used to continue tracing in Rasa.
Rasa Inspector
If you have enabled tracing in Rasa and are using the Rasa Inspector
debugging tool to try your assistant, note that in addition to the expected tracing span for the Agent.handle_message
method call, the tracing backend will collect independent tracing spans for the MessageProcessor.get_tracker
method calls. This is expected behaviour because the Rasa Inspector tool uses the Rasa HTTP API endpoints to
retrieve the conversation tracker which is required by the Inspector interface.
Action Server
The trace context from Rasa is sent along with requests to the custom action server using the W3C Trace Context Specification and then used to continue tracing the request through the custom action server.
Tracing is continued in the action server by instrumenting the webhook that receives custom actions. See Action server attributes for the attributes captured as part of the trace context.
See traced events for details on what attributes are made available as part of the trace context in Rasa.
Questions Tracing Can Help Answer
Tracing can help troubleshoot issues in development and production, by answering questions such as:
- How does a user message request get processed across different components i.e. dialogue understanding components (NLU,
CommandGenerator,CommandProcessorComponent), policies, and action server? - Why has my Rasa assistant decided to execute a certain action?
- Why has my Rasa assistant been slow to respond?
- Why have my custom actions been slow to execute?
- What is my OpenAI prompt token usage?
- What is the performance of my Rasa assistant across different flows?
- What is the performance of my Rasa assistant across different LLM models?
- What is the performance of my Rasa assistant across different vector stores?
Configuring a Tracing Backend or Collector
To configure a tracing backend or collector, add a tracing entry to your endpoints
i.e. in your endpoints.yml file, or in the relevant section of your Helm values in a deployment.
Enabling tracing activates Rasa's instrumentation layer. That layer also records Observability Metrics. If you configure a metrics block in your endpoints file, you must also enable tracing or no metric measurements will be collected.
Jaeger
To configure a Jaeger tracing backend, specify the type as jaeger.
endpoints.yml
tracing:
type: jaeger
host: localhost
port: 4317
service_name: rasa
sync_export: ~
OTEL Collector
Collectors are components that collect traces in a vendor-agnostic way and then forward them to various backends. For example, the OpenTelemetry Collector (OTEL) can collect traces from multiple different components and instrumentation libraries, and then export them to multiple different backends e.g. jaeger.
To configure an OTEL Collector, specify the type as otlp.
endpoints.yml
tracing:
type: otlp
endpoint: my-otlp-host:4317
insecure: false
service_name: rasa
root_certificates: ./tests/unit/tracing/fixtures/ca.pem
Traced Events
The Rasa service areas that are traceable cover the actions required to:
- train a model (i.e., the training of each graph component)
- handle a message
Model Training
Tracing is enabled for model training by instrumenting Rasa GraphTrainer and GraphNode classes.
GraphTrainer Attributes
The following attributes can be inspected during training of GraphTrainer:
training_typeof model configuration:- "NLU"
- "CORE"
- "BOTH"
- "END-TO-END"
languageof model configurationrecipe_nameused in theconfig.ymlfileoutput_filename: the location where the packaged model is savedis_finetuning: boolean argument, ifTrueenables incremental training
GraphNode Attributes
The following attributes are captured during the training (as well as prediction during message handling) of every graph node:
node_namecomponent_classfn_name: method of component class that gets called
Message Handling
The following Rasa classes are instrumented to enable tracing during message handling:
AgentMessageProcessorTrackerStoreLockStoreCompactLLMCommandGeneratorSearchReadyLLMCommandGeneratorNLUCommandAdapterFlowPolicyEnterpriseSearchPolicyInformationRetrievalEndpointConfig
In addition, the following Python modules were instrumented to enable tracing during message handling:
- command processor module, i.e. utility functions leveraged by the
CommandProcessorComponentto pre-process predicted commands - flow executor module, i.e. utility functions leveraged by
FlowPolicyto advance flows
Namely, these operations are now traceable:
- receiving a message
- parsing the message
- predicting commands
- pre-processing commands
- predicting the next action
- running the action
- advancing flows
- searching documents in vector stores for enterprise search
- generating LLM answers by policies e.g.
EnterpriseSearchPolicy - tracing prompt token usage
- retrieving and saving the tracker
- locking the conversation
- publishing to the event broker
- making requests to the action server or nlg server
- passing the trace context to the action server
Tracing in the Action Server
API Requests are traced as they flow through the action server by instrumenting the webhook that receives custom actions and other classes involved in the execution of custom actions.
Webhook Attributes
The following attributes are captured as part of the trace context of the webhook that receives custom actions;
http.method: the http method used to make the requesthttp.route: the endpoint of the requestnext_action: the name of the next action to be executedversion: the rasa version usedsender_id: the id of the conversationmessage_id: the unique message id