# SpanCreationOptions

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

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

## Properties

- **`addContextToTrace`** (`boolean`, optional) default: `true`
  Whether the filtering context will be added as span attributes
  to the span. See 'Filter'.
- **`autoSetSuccessStatus`** (`boolean`, optional) default: `false`
  Whether the span's status will be set to OK on completion, if
  it's still UNSET. See 'Filter'.
- **`canBeRoot`** (`boolean`, optional) default: `true`
  Whether the span will be able to start a new trace. If false, it will only
  be able to be added to an existing trace.
- **`countMetric`** (`boolean`, optional) default: `false`
  Whether the span will be counted in the insights_trace_count metric. See TracesSettings.countMetric.
- **`countMetricOnDisabledSpans`** (`boolean`, optional) default: `false`
  Whether the span will be counted in the insights_trace_count metric if disabled. See TracesSettings.countMetric.
- **`disableNesting`** (`boolean`, optional)
  Forces the span to create a new trace.
- **`disablePropagation`** (`boolean`, optional) default: `false`
  Whether the span will not inject its propagation info into data
  transfer objects for span nesting across system boundaries.
- **`durationMetric`** (`boolean`, optional) default: `false`
  Whether the span will be counted in the insights_trace_duration metric. See TracesSettings.durationtMetric.
- **`durationMetricOnDisabledSpans`** (`boolean`, optional) default: `false`
  Whether the span will be counted in the insights_trace_count metric if disabled. See TracesSettings.durationMetric.
- **`enabled`** (`boolean`, optional) default: `true`
  Whether the span will be created or will be a no-op. See 'Filter'.
- **`forceChildTracing`** (`boolean`, optional) default: `false`
  If true, any child spans (including nested spans across sytem boundaries)
  will be forced to be traced, even if their span filter configuration
  is set to not enabled.
- **`forceStatus`** (`SpanStatusCode`, optional)
  If set, will force the span to have this status code, regardless of anything set explicitly
  or any errors caught automatically.
- **`level`** (`keyof typeof SpanVerbosity`, optional) default: `INFO`
  Default span attribute verbosity level. See 'Filter'.
- **`linkToParent`** (`boolean`, optional) default: `false`
  If `true`, the span is linked to its parent instead of being parented to
  it: it starts a trace of its own, and carries an OTEL span link to the
  span that would have been its parent (the link has the attribute
  `linkToParent: true`, to tell it from other links). The connection is
  kept, without the span becoming part of the parent's trace - for a parent
  that is long-lived or unrelated in meaning, such as the application
  startup span that every span created during the startup window is nested
  under by default.

  Applies wherever the parent comes from: an explicit propagation info, the
  current tracing state, or the default propagation info. The span's own
  children are nested under it as usual, in its new trace. Without a parent
  there is nothing to link, and the span is an ordinary root; the same goes
  for `disableNesting`, which leaves the span without a parent.

  The parent still counts as a parent for `canBeRoot` (a span that cannot
  be a root is still created) and for the parent's `forceChildTracing`.
  Sampling is decided for the new trace on its own - the parent's sampling
  decision is not inherited.
- **`log`** (`boolean | TracesAsLogsOptions`, optional) default: `false`
  "Traces as logs": whether the span is also published as a log entry, using the `traceLogger`
  passed to the builder instance when building the Traces module. `true` logs the span when it
  is enabled; `false` turns the logging off altogether; a `TracesAsLogsOptions` object says
  what is logged in more detail.

  The places the option can be set in - a matching filter, the span's own options, the
  `defaults` - are combined option by option: `defaults: { log: { includeResourceAttributes: true } }`
  with `log: true` in a filter logs that filter's spans with their resource attributes.
- **`maxAttributeDepth`** (`number`, optional) default: `5`
  How deep addData method should recurse into objects when adding
  attributes to spans.
- **`minDurationMs`** (`number`, optional) default: `0`
  If specified, spans whose duration is lower than this will not be sampled.
- **`otelSpanOptions`** (`SpanOptions`, optional)
  OTEL span options
- **`overrideDefaultFilters`** (`boolean`, optional) default: `false`
  If `true`, this filter rule will be matched before any default filters provided
  by io.Connect. The default filters are usually meant to reduce verbosity by not
  tracing some internal operations by default, but you can use this property to
  force them to be traced.
  If `false`, default filters will be matched before this filtering rule.
- **`resultMetric`** (`boolean`, optional) default: `false`
  Whether the span will be counted in the insights_trace_result metric. See TracesSettings.resultMetric.
- **`resultMetricOnDisabledSpans`** (`boolean`, optional) default: `false`
  Whether the span will be counted in the insights_trace_result metric if disabled. See TracesSettings.resultMetric.
- **`sample`** (`number | boolean`, optional) default: `true`
  Default sampling setting/probability. See 'SamplingSettings'.
- **`stopPropagationIfSpanIsDisabled`** (`boolean`, optional) default: `false`
  If a tracing span is disabled by filter, setting this to "true" will stop the propagation
  of trace nesting info across it.

## Related types

- [SpanStatusCode](https://docs.interop.io/browser/reference/javascript/insights/spanstatuscode/index.md)
- [SpanVerbosity](https://docs.interop.io/browser/reference/javascript/insights/spanverbosity/index.md)
- [TracesAsLogsOptions](https://docs.interop.io/browser/reference/javascript/insights/tracesaslogsoptions/index.md)
