# TracingState

**Kind**: interface | **Module**: [Insights](https://docs.interop.io/browser/reference/javascript/insights/index.md)

**Source**: https://docs.interop.io/browser/reference/javascript/insights/tracingstate/index.html

## Properties

- **`addEvent`** (`( name: string, attributesOrStartTime?: Attributes | TimeInput, startTime?: TimeInput ) => this`, required)
- **`addLink`** (`(link: Link) => this`, required)
  Adds a link to another span - for a link that could not be given at creation, such as a
  parent's link to a child. Until the span ends. On a span recorded by the
  `BufferingTracesManager` the link is made at replay time, rewritten like the links given at
  creation (see `spanContext`).
- **`autoSetSuccessStatus`** (`boolean`, optional)
  `autoSetSuccessStatus` as resolved for this span (matching filter, span options, defaults):
  whether its status is set to OK when its callback completes with the status still UNSET.
  For code that ends the span itself, inside the callback - a span that has ended is past
  having its status set, so such code has to do what the manager would have done.
- **`context`** (`Context`, optional)
- **`enabled`** (`boolean`, required)
  If false, this is a placeholder object, and all its methods
  are no-ops, with the possible exception of getPropagationInfo()
  and injectPropagationInfo()
- **`endTime`** (`Date`, optional)
- **`getPropagationInfo`** (`() => PropagationInfo | null`, required)
  Gets the propagation info for the current span (see https://www.w3.org/TR/trace-context/#tracestate-field)
- **`id`** (`string`, optional)
- **`injectPropagationInfo`** (`(carrier: PropagationInfoCarrier & object) => void`, required)
  Sets a hidden property in the object that can be used to restore propagation
  information after serialization and deserialization (see withSpan 'propagationInfo' argument
  and Traces.extractPropagationInfo() method).
- **`isRecording`** (`Span["isRecording"]`, required)
- **`level`** (`keyof typeof SpanVerbosity`, required)
- **`matchingFilter`** (`SpanFilter | null`, optional)
- **`recordException`** (`Span["recordException"]`, required)
- **`source`** (`string`, required)
- **`span`** (`Span`, optional)
- **`spanContext`** (`() => ReturnType<Span["spanContext"]> | undefined`, required)
  The context of the span - what a link to it is made with - or `undefined` when there is no
  span (disabled by a filter, telemetry off). A span recorded by the `BufferingTracesManager`
  has a synthetic one until it is replayed, which the replay rewrites in the links made with it.
- **`startTime`** (`Date`, optional)
- **`status`** (`SpanStatus`, optional)
- **`traceId`** (`string`, optional)
- **`updateName`** (`(name: string) => this`, required)

## Methods

### addData

Adds data to the span - as attributes, flattened - when the span records the given
verbosity level: a level at or above the span's own `level`.

`data` given as a function is computed lazily: the function is called only when the
span records the level, once, so a value that is expensive to work out costs nothing on
a span that does not record it - or on a disabled span, which never calls it. A function
that throws is handled like any other error inside the library: swallowed (and logged)
in `errorlessMode`, thrown to the caller otherwise; one that returns nothing adds
nothing.

On a span of the startup span buffer (`BufferingTracesManager`) the level is not known
yet: the function is kept and called when the span is replayed into the real manager -
once, and only if the span records the level - so it should not depend on state that
changes in the meantime. A function that throws at the replay is logged, and its data
left out.

```ts
(level: SpanVerbosity | keyof typeof SpanVerbosity, data: object | (() => object)) => void
```

**Parameters**

- **`level`** (`SpanVerbosity | keyof typeof SpanVerbosity`, required)
- **`data`** (`object | (() => object)`, required)

**Returns**: `void`

### end

Ends the current span. Same as endSpan().

```ts
() => void
```

**Returns**: `void`

### endSpan

```ts
(endTime?: Date, allowDoubleEnd?: boolean) => Promise<void>
```

**Parameters**

- **`endTime`** (`Date`, optional)
- **`allowDoubleEnd`** (`boolean`, optional)

**Returns**: `Promise<void>`

## Related types

- [PropagationInfo](https://docs.interop.io/browser/reference/javascript/insights/propagationinfo/index.md)
- [SpanFilter](https://docs.interop.io/browser/reference/javascript/insights/spanfilter/index.md)
- [SpanStatus](https://docs.interop.io/browser/reference/javascript/insights/spanstatus/index.md)
- [SpanVerbosity](https://docs.interop.io/browser/reference/javascript/insights/spanverbosity/index.md)
