> For the complete documentation index, see [llms.txt](https://docs.testvibe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testvibe.com/load-testing/server-telemetry.md).

# Server Telemetry

Client-side numbers tell you what users experience under load; server telemetry tells you *why*. Install the TestVibe agent in the application you are testing and your results gain live server-side **CPU**, **memory**, **session**, and **custom** metrics — rendered next to the client-side charts.

The metrics appear in two places:

* **Load test results** — server vitals next to the client-side charts.
* **Dashboard → Live Servers** — the same vitals streaming in real time while you watch.

The agent only sends data while one of your load runs is active or someone is watching the Dashboard — there is **no idle traffic**, and it is always best-effort so it can never disturb your application.

## What you'll need

1. A **TestVibe API key** (`tvb_…`, workspace-scoped) — TestVibe → **Settings → CLI & API keys**. See [API keys](/account-settings/api-keys.md). The agent discovers your projects from the key.
2. The agent for your stack (below). The .NET agent is the [`TestVibe.Telemetry`](https://www.nuget.org/packages/TestVibe.Telemetry) NuGet package; it discovers your projects from the API key, so you don't even need a project id.

## .NET

Install the package:

```sh
dotnet add package TestVibe.Telemetry
```

It targets `netstandard2.0`, so it runs on .NET Framework 4.6.1+, .NET Core 2.0+, and .NET 5–10+. Register it once at startup. The optional `SessionCount` callback unlocks **Sessions** and **Memory / session**; wire it to whatever represents an active session in your app.

{% tabs %}
{% tab title="ASP.NET Core" %}

```csharp
// Program.cs
using TestVibe;

var builder = WebApplication.CreateBuilder(args);
// ... services ...
var app = builder.Build();

Telemetry.Register(
    builder.Configuration["TestVibe:Server"] ?? "https://app.testvibe.com",
    builder.Configuration["TestVibe:ApiKey"], // tvb_… from Settings → CLI & API keys
    new TelemetryOptions
    {
        // Optional: report a live count (e.g. active SignalR connections or signed-in users).
        SessionCount = () => MyConnectionCounter.Current,
    });

app.Run();
```

{% endtab %}

{% tab title="Worker / Generic Host" %}

```csharp
// Program.cs (Worker Service, or any Generic Host)
using TestVibe;

var host = Host.CreateApplicationBuilder(args).Build();

Telemetry.Register("https://app.testvibe.com", Environment.GetEnvironmentVariable("TESTVIBE_API_KEY"));

host.Run();
```

{% endtab %}

{% tab title="Console / daemon" %}

```csharp
using TestVibe;

class Program
{
    static async Task Main()
    {
        TestVibe.Telemetry.Register("https://app.testvibe.com", "tvb_…");
        await RunForeverAsync();
    }
}
```

{% endtab %}

{% tab title="WinForms / WPF" %}

```csharp
// Program.cs / App startup
using TestVibe;

[STAThread]
static void Main()
{
    TestVibe.Telemetry.Register("https://app.testvibe.com", "tvb_…");
    Application.Run(new MainForm());
}
```

{% endtab %}

{% tab title="Wisej.NET" %}

```csharp
// Program.cs — register once in the static constructor
using TestVibe;

static Program()
{
    Telemetry.Register("https://app.testvibe.com", "tvb_…", new TelemetryOptions
    {
        // Wisej tracks live sessions for you — report the built-in count.
        SessionCount = () => Wisej.Web.Application.SessionCount,
    });
}
```

{% endtab %}
{% endtabs %}

### Custom metrics, info & errors

Anywhere in your app:

```csharp
// Gauges — chart alongside CPU/memory (latest value wins, up to 20 metrics).
TestVibe.Telemetry.ReportMetric("Orders/min", ordersPerMinute);

// Static facts shown in the server card header.
TestVibe.Telemetry.ReportInfo("Region", "westeurope");

// Errors — grouped + persisted under Dashboard → Telemetry → Errors & exceptions.
// Unhandled exceptions are captured automatically; report handled ones too:
try { DoWork(); }
catch (Exception ex) { TestVibe.Telemetry.ReportError(ex); throw; }
```

## Node.js

For Node services, copy the single-file agent shown in **Settings → Telemetry** (`testvibe-load-agent.js`, no dependencies) and start it once at boot:

```javascript
const { startTestVibeLoadAgent } = require('./testvibe-load-agent');

startTestVibeLoadAgent({
  server: 'https://app.testvibe.com',
  apiKey: 'tvb_…',               // Settings → CLI & API keys
  project: '<your-project-id>',
  sessions: () => myActiveSessions, // optional
});
```

## Reading server metrics

* **CPU** climbing toward saturation while latency p95 rises is the classic capacity ceiling — scale up or optimize before raising thresholds.
* **Memory** growing run-over-run without recovering suggests a leak the load test is exposing; **Memory / session** isolates whether it's per-session.
* **Sessions** confirms the load actually produced the concurrency you configured.

## Related help

* [Run a load test and read results](/load-testing/run-a-load-test-and-read-results.md)
* [API keys](/account-settings/api-keys.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.testvibe.com/load-testing/server-telemetry.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
