hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
91 lines (48 loc) • 1.62 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [Telemetry](./server.telemetry.md) > [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) => 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);
});
```