How it works
Tracing works by creating and updating spans. Spans can have parents and children, which means that they can be connected to each other. By default, all task completions or knowledge base operations are automatically attached to a span which will have the name of the task. In the return values of operations the span_id is listed. All operations have a parent_span_id which can be used to connect the operation to a span.Creating new spans
Task completions can be attached to spans. Here is a simple example where we create a root span named “data_processing”:It is possible to create flexible hierarchies of spans to capture the run of an agent or chatbot in the best way possible. It is often good to think about a span as a container of some kind of higher level operation. For example, for a chatbot you may want a root span to be a session, each round of the chat a round, and then have all underlying task completions inside the round span.
Setting span input and output fields
Span input and output fields can be useful to surface information. Here we update the root span with information on what will be processed and the final output:Since it’s possible to choose exactly what to display in the input and output fields of a span it is a good way to render information for more easy digestion, maybe for non-technical experts and other peers
Adding metrics to spans
It is possible to add metrics to spans, to catch results of evaluations or performance measurements. Metrics can be filtered for in the tracing view in the dashboard. Here is a simple example :We recommend thinking about metrics as a way to store various performance evaluations of the feature you are building. Metrics can hold things like thumbs up/down, results of tests from requirements and so forth.