Learn how to trace your system with Openlayer
Set environment variables
Annotate the code you want to trace
generate_answer
function in the example above uses an OpenAI LLM.
However, tracing also works for other LLM providers. If you set up any of the
streamlined approaches described in the Publishing data
guide, it will get added to the trace as well.Use the annotated code
main
:main
function has two nested steps: retrieve_context
, and
generate_answer
. The generate_answer
has a chat completion call within it. The cost,
number of tokens, latency, and other metadata are all computed automatically behind the
scenes.