.NET Telemetry

Capture extra events that preceded your payloads...

What is the Telemetry?

The Rollbar.NET SDK provides a mechanism to collect (independently from its logger components) some additional runtime information "bread crumbs" in the form of Telemetry events and keeps them within the configurable fixed-depth Telemetry queue. It provides an API for capturing telemetry events within the queue so that whenever the Rollbar logger reports any data to Rollbar API the Telemetry events available in the Telemetry queue at the time of logging are automatically attached to the logger payload. This Telemetry data is intended to provide extra information about the events preceding the logging event that could be useful when analyzing the logging event itself.

Currently, Telemetry events are categorized by types. For example, network telemetry events, error telemetry events, manual telemetry events, etc.

The Telemetry functionality of the SDK can be configured either in code or via an application configuration file. It can be either enabled or disabled. It allows configuration of the Telemetry queue depth. It also allows the filtering of what telemetry types to be included (or not) into the collection. In addition, it allows you to specify if Telemetry data auto-capture (if possible) should be enabled or not (however, the auto-capture functionality yet to be finalized and implemented soon).

The Telemetry infrastructure is built around an application-wide service called TelemetryCollector that is implemented as a singleton. It provides API for configuring the Telemetry behavior, capturing Telemetry events as needed and “snapping” all the available captured telemetry events at any given time. The fixed depth TelemetryQueue is hosted internally by the TelemetryCollector.

Configuration

In Code

/// <summary>
/// Configures the rollbar telemetry.
/// </summary>
private static void ConfigureRollbarTelemetry()
{
  TelemetryConfig telemetryConfig = new TelemetryConfig(
    telemetryEnabled: true,
    telemetryQueueDepth: 3
  );
  TelemetryCollector.Instance.Config.Reconfigure(telemetryConfig);
}

Via appsettings.json Application Configuration File

Via app.config Application Configuration File

Capturing Telemetry Events Manually

TelemetryCollector.Instance.Capture(
                new Telemetry(
                    TelemetrySource.Client,
                    TelemetryLevel.Info,
                    new LogTelemetry("Something interesting happened.")
                    )
                );

            TelemetryCollector.Instance.Capture(
                new Telemetry(
                    TelemetrySource.Client,
                    TelemetryLevel.Error,
                    new ErrorTelemetry(new System.Exception("Worth mentioning!"))
                    )
                );

            TelemetryCollector.Instance.Capture(
                new Telemetry(
                    TelemetrySource.Client,
                    TelemetryLevel.Error,
                    new ManualTelemetry(new Dictionary<string, object>() { 
                { "param1", "value1" }, 
                { "param2", "value2" }, }
              )
                  )
                );

Did this page help you?