<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md) &gt; [startSpan](./server.telemetry.startspan.md)

## Telemetry.startSpan() method

Executes a callback function within a performance monitoring span.

**Signature:**

```typescript
static startSpan<T>(options: TelemetrySpanOptions, callback: (span?: Sentry.Span) => T): T;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

options


</td><td>

[TelemetrySpanOptions](./server.telemetryspanoptions.md)


</td><td>

Configuration for the telemetry span including operation type and attributes.


</td></tr>
<tr><td>

callback


</td><td>

(span?: Sentry.Span) =&gt; T


</td><td>

The function to execute within the performance span.


</td></tr>
</tbody></table>
**Returns:**

T

The return value of the callback function.

## Remarks

This method provides zero-overhead performance monitoring in development environments. In production with Sentry enabled and `SENTRY_ENABLE_TRACING=true`<!-- -->, it creates performance spans for monitoring. The span data is only transmitted to Sentry when performance issues are detected.

## Example


```typescript
const result = Telemetry.startSpan({
  operation: TelemetrySpanOperation.ENTITIES_TICK,
  attributes: {
    entityCount: entities.length,
    worldId: world.id,
  },
}, () => {
  return processEntities(entities);
});
```
\*\*Category:\*\* Telemetry

