Table of Contents

Class Reporter

Namespace
Pamoja.Telemetry
Assembly
Pamoja.Telemetry.dll

Records events, ships the ones worth their bytes, and counts them all.

public sealed class Reporter : IDisposable
Inheritance
Reporter
Implements
Inherited Members

Remarks

A node that ships every event it produces will spend more on reporting than on the job it was installed to do, and on a satellite link that is money. The reporter keeps counting what it drops, so the aggregate picture survives even when the detail cannot be sent.

Constructors

Reporter(TelemetryLevel)

Creates a reporter that ships events at or above a level.

public Reporter(TelemetryLevel threshold = TelemetryLevel.Info)

Parameters

threshold TelemetryLevel

The lowest level to ship.

Exceptions

PamojaException

The native reporter could not be created.

Properties

Dropped

Gets how many events the threshold dropped.

public uint Dropped { get; }

Property Value

uint

Emitted

Gets how many events passed the threshold and were shipped.

public uint Emitted { get; }

Property Value

uint

Threshold

Gets or sets the level this reporter is shipping from.

public TelemetryLevel Threshold { get; set; }

Property Value

TelemetryLevel

Total

Gets how many events have been seen across every level.

public uint Total { get; }

Property Value

uint

Methods

AdaptTo(LinkCost)

Moves the threshold to match what the link now costs.

public void AdaptTo(LinkCost cost)

Parameters

cost LinkCost

What the link currently costs.

Count(TelemetryLevel)

Returns how many events have been seen at a level, shipped or not.

public uint Count(TelemetryLevel level)

Parameters

level TelemetryLevel

The level to count.

Returns

uint

The number of events recorded at that level.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Record(TelemetryEvent)

Records an event, returning it when it should be shipped.

public TelemetryEvent? Record(TelemetryEvent telemetryEvent)

Parameters

telemetryEvent TelemetryEvent

The event that occurred.

Returns

TelemetryEvent?

The same event when it passed the threshold, or null when it was counted and dropped.

Remarks

Only the level reaches the native reporter, because the level is the whole of what it decides on. The event comes straight back when it passed.

Snapshot()

Takes a snapshot of the counters to ship in place of the stream.

public TelemetrySnapshot Snapshot()

Returns

TelemetrySnapshot

The per-level counts and the shipped and dropped totals.

ThresholdFor(LinkCost)

Returns the level a link cost calls for.

public static TelemetryLevel ThresholdFor(LinkCost cost)

Parameters

cost LinkCost

What the link currently costs.

Returns

TelemetryLevel

The lowest level still worth its bytes at that cost.