UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

126 lines (66 loc) 2.46 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [Telemetry](./server.telemetry.md) ## Telemetry class Manages performance telemetry and error tracking through your Sentry.io account. **Signature:** ```typescript export default class Telemetry ``` ## Remarks The Telemetry class provides low-overhead performance monitoring and error tracking through Sentry (https://sentry.io) integration and your provided Sentry DSN. It automatically tracks critical game loop operations like physics simulation, entity updates, network synchronization, and more. The system only sends telemetry data when errors or slow-tick performance issues are detected, minimizing bandwidth and storage costs. ## Example ```typescript // Initialize Sentry for production telemetry Telemetry.initializeSentry('MY_SENTRY_PROJECT_DSN'); // Wrap performance-critical code in spans Telemetry.startSpan({ operation: TelemetrySpanOperation.CUSTOM_OPERATION, attributes: { // any arbitrary attributes you want to attach to the span playerCount: world.playerManager.connectedPlayers.length, entityCount: world.entityManager.entityCount, }, }, () => { // Your performance-critical code here performExpensiveOperation(); }); // Get current process statistics const stats = Telemetry.getProcessStats(); console.log(`Heap usage: ${stats.jsHeapUsagePercent * 100}%`); ``` ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [getProcessStats(asMeasurement)](./server.telemetry.getprocessstats.md) </td><td> `static` </td><td> Gets current Node.js process memory and performance statistics. </td></tr> <tr><td> [initializeSentry(sentryDsn, tickTimeMsThreshold)](./server.telemetry.initializesentry.md) </td><td> `static` </td><td> Initializes Sentry telemetry with the provided DSN. </td></tr> <tr><td> [sentry()](./server.telemetry.sentry.md) </td><td> `static` </td><td> Gets the Sentry SDK instance for advanced telemetry operations. </td></tr> <tr><td> [startSpan(options, callback)](./server.telemetry.startspan.md) </td><td> `static` </td><td> Executes a callback function within a performance monitoring span. </td></tr> </tbody></table>