> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FiddlerSpan

> Base wrapper around an OpenTelemetry Span with Fiddler-specific

Base wrapper around an OpenTelemetry Span with Fiddler-specific
attribute helpers.

All setter methods return `this` for fluent chaining.

## Methods

### `constructor(span: Span)`

<ParamField path="span" type="Span" required={true}>
  The underlying OpenTelemetry span instance.
</ParamField>

### `end()`

Mark the span as successful and record its end timestamp.

### `recordError(error: string | Error)`

Record an error on this span and set its status to `ERROR`.

<ParamField path="error" type="string | Error" required={true}>
  An Error instance or error message string.
</ParamField>

### `setAttribute(key: string, value: string | number | boolean): this`

Set an arbitrary attribute on the span.

<ParamField path="key" type="string" required={true}>
  Attribute key (e.g. `"gen_ai.request.model"`).
</ParamField>

<ParamField path="value" type="string | number | boolean" required={true}>
  Attribute value.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setConversationId(id: string): this`

Tag this span with a conversation/session identifier.

<ParamField path="id" type="string" required={true}>
  Unique conversation or session ID.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setInput(input: unknown): this`

Set the user-facing input for this span.

Writes to the `gen_ai.llm.input.user` attribute after safely
serializing non-string values.

<ParamField path="input" type="unknown" required={true}>
  The input value (string or serializable object).
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setOutput(output: unknown): this`

Set the output/response for this span.

Writes to the `gen_ai.llm.output` attribute after safely
serializing non-string values.

<ParamField path="output" type="unknown" required={true}>
  The output value (string or serializable object).
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>
