Learn how to control the capture and structure of input and output data for traces and spans with the LangWatch TypeScript SDK.
tracer.withActiveSpan()
or tracer.startActiveSpan()
, the SDK attempts to automatically capture:
getLangWatchTracer()
and LangWatchTracer
for more details on data capture configuration.setInput()
and setOutput()
methods on span objects.
This is useful for:
ChatMessage
objects).tracer.withActiveSpan()
or tracer.startActiveSpan()
, you can set inputs and outputs directly on the span object.
setInput()
and setOutput()
methods. This is particularly useful when the input/output data is determined or refined during the operation.
setInput()
and setOutput()
methods on LangWatchSpan
objects are versatile and support multiple data types. See the reference for LangWatchSpan
methods."text"
type."json"
type. This is useful for structured data."chat_messages"
type. This ensures proper display and analysis in the LangWatch UI."raw"
type."list"
type."chat_messages"
type.
setInput()
and setOutput()
.input
or output
to null
or an empty object via the setInput()
or setOutput()
methods to remove previously captured data if it’s no longer relevant.setInput()
and setOutput()
methods, and appropriate data formatting (especially "chat_messages"
for conversations), you can ensure that your traces provide clear, relevant, and secure insights into your LLM application’s behavior.