Langtrace SDK allows you to group related operations together using the @with_langtrace_root_span
decorator for Python or WithLangTraceRootSpan
for Typescript.
A root span is the top-level span in a trace that encompasses all related operations. It provides a hierarchical structure to your traces, making it easier to understand the relationship between different operations in your application.
A typical application may have multiple operations that are related to each other. For example, in a RAG workflow, the user’s input is embedded using a model, a semantic search is done on a VectorDB, and the results are again given back to the model to get a natural language response. In such cases, it is useful to group these operations together under a single root span. This allows you to see the entire flow of operations in a single trace.
Step 1: Install and initialize Langtrace SDK. Refer to the installation guide for more information.
Step 2: Use the with_langtrace_root_span
decorator (Python) or WithLangTraceRootSpan
(Typescript) function. Example below:
The following examples demonstrate how to group traces in a typical RAG (Retrieval-Augmented Generation) workflow:
If you’re not seeing grouped traces as expected:
withLangTraceRootSpan
function or @with_langtrace_root_span
decorator.Langtrace SDK allows you to group related operations together using the @with_langtrace_root_span
decorator for Python or WithLangTraceRootSpan
for Typescript.
A root span is the top-level span in a trace that encompasses all related operations. It provides a hierarchical structure to your traces, making it easier to understand the relationship between different operations in your application.
A typical application may have multiple operations that are related to each other. For example, in a RAG workflow, the user’s input is embedded using a model, a semantic search is done on a VectorDB, and the results are again given back to the model to get a natural language response. In such cases, it is useful to group these operations together under a single root span. This allows you to see the entire flow of operations in a single trace.
Step 1: Install and initialize Langtrace SDK. Refer to the installation guide for more information.
Step 2: Use the with_langtrace_root_span
decorator (Python) or WithLangTraceRootSpan
(Typescript) function. Example below:
The following examples demonstrate how to group traces in a typical RAG (Retrieval-Augmented Generation) workflow:
If you’re not seeing grouped traces as expected:
withLangTraceRootSpan
function or @with_langtrace_root_span
decorator.