Table of Contents

Class AssetRuntimeHealthReporter

Namespace
Azure.Iot.Operations.Services.AssetAndDeviceRegistry
Assembly
Azure.Iot.Operations.Services.dll

A class for smartly sending runtime health events for a specific asset to the Azure Device Registry service

public class AssetRuntimeHealthReporter : IAsyncDisposable
Inheritance
AssetRuntimeHealthReporter
Implements
Inherited Members

Remarks

This class has two main features that differentiate it from just directly calling the runtime health update APIs like ReportDatasetRuntimeHealthAsync(string, string, string, List<DatasetsRuntimeHealthEvent>, TimeSpan?, CancellationToken):

  1. De-duplication of dataset/stream/event/management action runtime healths. This allows you to write your connector code such that it repeatedly calls an API like ReportDatasetHealthStatusAsync(List<DatasetsRuntimeHealthEvent>, TimeSpan?, CancellationToken) even if the runtime health has not changed as this client will cache the last sent runtime health and check if the new runtime health actually needs to be forwarded to the service.
  2. Periodic reporting of the last known runtime healths of the datasets/streams/events/management actions with updated timestamps. Connectors are advised to periodically send these updates to ensure that the Azure Device Registry service has an up-to-date picture of the runtime health of each dataset/stream/event/management action and this class handles that for you. Additionally, the periodic updates can be paused for specific datasets/streams/events/management actions when their runtime health becomes unknown. This background reporting will send the runtime health for all non-paused datasets/streams/events/management actions at once and the period that it does this can be changed with SetRuntimeHealthBackgroundReportingIntervalAsync(TimeSpan, CancellationToken).

Constructors

AssetRuntimeHealthReporter(IAzureDeviceRegistryClient, string, string, string, TimeSpan?)

Create a new runtime health reporter for a given asset

public AssetRuntimeHealthReporter(IAzureDeviceRegistryClient azureDeviceRegistryClient, string deviceName, string inboundEndpointName, string assetName, TimeSpan? reportingPeriod = null)

Parameters

azureDeviceRegistryClient IAzureDeviceRegistryClient

The Azure Device Registry client used to send these runtime health events.

deviceName string

The name of the device.

inboundEndpointName string

The name of the inbound endpoint

assetName string

The name of the asset.

reportingPeriod TimeSpan?

The interval at which to send background reports.

Remarks

Background reporting does not start until the first runtime health of a dataset/stream/event/management action is set by calling a method like ReportDatasetHealthStatusAsync(string, RuntimeHealth, TimeSpan?, CancellationToken).

Methods

CancelHealthStatusReportingAsync(CancellationToken)

Stop all background reporting.

public Task CancelHealthStatusReportingAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

Generally, this method should only be called if the asset this client reports for is no longer available.

DisposeAsync()

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

public virtual ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

DisposeAsync(bool)

public virtual ValueTask DisposeAsync(bool disposing)

Parameters

disposing bool

Returns

ValueTask

PauseReportingDatasetAsync(string, CancellationToken)

Pause background reporting until a new health status is set for this dataset

public Task PauseReportingDatasetAsync(string datasetName, CancellationToken cancellationToken = default)

Parameters

datasetName string

The dataset to pause health status reporting for.

cancellationToken CancellationToken

Returns

Task

Remarks

This is used to signal that the last known health status may no longer be applicable. This does not affect background reporting of other datasets/streams/events/management actions that were already active.

PauseReportingEventAsync(string, string, CancellationToken)

Pause background reporting until a new health status is set for this event

public Task PauseReportingEventAsync(string eventGroupName, string eventName, CancellationToken cancellationToken = default)

Parameters

eventGroupName string

The event group whose event should pause reporting.

eventName string

The event within the given event group that should pause reporting

cancellationToken CancellationToken

Returns

Task

Remarks

This is used to signal that the last known health status may no longer be applicable.

PauseReportingManagementActionAsync(string, string, CancellationToken)

Pause background reporting until a new health status is set for this event

public Task PauseReportingManagementActionAsync(string managementGroupName, string managementActionName, CancellationToken cancellationToken = default)

Parameters

managementGroupName string

The management group whose action should pause reporting.

managementActionName string

The action within the given management group that should pause reporting

cancellationToken CancellationToken

Returns

Task

Remarks

This is used to signal that the last known health status may no longer be applicable. This does not affect background reporting of other datasets/streams/events/management actions that were already active.

PauseReportingStreamAsync(string, CancellationToken)

Pause background reporting until a new health status is set for this stream

public Task PauseReportingStreamAsync(string streamName, CancellationToken cancellationToken = default)

Parameters

streamName string

The stream to pause health status reporting for.

cancellationToken CancellationToken

Returns

Task

Remarks

This is used to signal that the last known health status may no longer be applicable. This does not affect background reporting of other datasets/streams/events/management actions that were already active.

ReportDatasetHealthStatusAsync(List<DatasetsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report a batch of runtime healths of datasets if any of them are worth reporting.

public Task ReportDatasetHealthStatusAsync(List<DatasetsRuntimeHealthEvent> datasetRuntimeHealths, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

datasetRuntimeHealths List<DatasetsRuntimeHealthEvent>

The batch of dataset runtime healths.

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for any of these datasets, or it was paused, then background reporting will start/resume. This method will only send the runtime healths in this batch that are not functionally identical to their previously reported runtime health (identical other than timestamp). If none of these runtime healths are worth reporting, then no telemetry will be sent.

ReportDatasetHealthStatusAsync(string, RuntimeHealth, TimeSpan?, CancellationToken)

Report the runtime health of a single dataset if it is worth reporting.

public Task ReportDatasetHealthStatusAsync(string datasetName, RuntimeHealth datasetRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

datasetName string

The name of the dataset

datasetRuntimeHealth RuntimeHealth

The runtime health of that dataset

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for this dataset, or it was paused, then background reporting will start/resume. If this runtime health is functionally identical to the previously reported runtime health (identical other than timestamp), then no telemetry will be sent to the Azure Device Registry service.

ReportEventHealthStatusAsync(List<EventsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report a batch of runtime healths of events if any of them are worth reporting.

public Task ReportEventHealthStatusAsync(List<EventsRuntimeHealthEvent> eventRuntimeHealths, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

eventRuntimeHealths List<EventsRuntimeHealthEvent>

The batch of event runtime healths.

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for any of these events, or it was paused, then background reporting will start/resume. This method will only send the runtime healths in this batch that are not functionally identical to their previously reported runtime health (identical other than timestamp). If none of these runtime healths are worth reporting, then no telemetry will be sent.

ReportEventHealthStatusAsync(string, string, RuntimeHealth, TimeSpan?, CancellationToken)

Report the runtime health of a single event if it is worth reporting.

public Task ReportEventHealthStatusAsync(string eventGroupName, string eventName, RuntimeHealth eventRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

eventGroupName string

The name of the event group that the event belongs to

eventName string

The name of the event

eventRuntimeHealth RuntimeHealth

The runtime health of that event

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for this event, or it was paused, then background reporting will start/resume. If this runtime health is functionally identical to the previously reported runtime health (identical other than timestamp), then no telemetry will be sent to the Azure Device Registry service.

ReportManagementActionHealthStatusAsync(List<ManagementActionsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report a batch of runtime healths of management actions if any of them are worth reporting.

public Task ReportManagementActionHealthStatusAsync(List<ManagementActionsRuntimeHealthEvent> managementActionRuntimeHealths, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

managementActionRuntimeHealths List<ManagementActionsRuntimeHealthEvent>

The batch of management action runtime healths.

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for any of these management actions, or it was paused, then background reporting will start/resume. This method will only send the runtime healths in this batch that are not functionally identical to their previously reported runtime health (identical other than timestamp). If none of these runtime healths are worth reporting, then no telemetry will be sent.

ReportManagementActionHealthStatusAsync(string, string, RuntimeHealth, TimeSpan?, CancellationToken)

Report the runtime health of a single management action if it is worth reporting.

public Task ReportManagementActionHealthStatusAsync(string managementGroupName, string managementActionName, RuntimeHealth managementActionRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

managementGroupName string

The name of the management group that the management action belongs to

managementActionName string

The name of the event

managementActionRuntimeHealth RuntimeHealth

The runtime health of that management action

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for this management action, or it was paused, then background reporting will start/resume. If this runtime health is functionally identical to the previously reported runtime health (identical other than timestamp), then no telemetry will be sent to the Azure Device Registry service.

ReportStreamHealthStatusAsync(List<StreamsRuntimeHealthEvent>, TimeSpan?, CancellationToken)

Report a batch of runtime healths of streams if any of them are worth reporting.

public Task ReportStreamHealthStatusAsync(List<StreamsRuntimeHealthEvent> streamRuntimeHealths, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

streamRuntimeHealths List<StreamsRuntimeHealthEvent>

The batch of stream runtime healths.

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for any of these streams, or it was paused, then background reporting will start/resume. This method will only send the runtime healths in this batch that are not functionally identical to their previously reported runtime health (identical other than timestamp). If none of these runtime healths are worth reporting, then no telemetry will be sent.

ReportStreamHealthStatusAsync(string, RuntimeHealth, TimeSpan?, CancellationToken)

Report the runtime health of a single stream if it is worth reporting.

public Task ReportStreamHealthStatusAsync(string streamName, RuntimeHealth streamRuntimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)

Parameters

streamName string

The name of the stream

streamRuntimeHealth RuntimeHealth

The runtime health of that stream

telemetryTimeout TimeSpan?

The timeout to use when sending this telemetry (if any telemetry is sent).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

Remarks

If background reporting has not started for this stream, or it was paused, then background reporting will start/resume. If this runtime health is functionally identical to the previously reported runtime health (identical other than timestamp), then no telemetry will be sent to the Azure Device Registry service.

SetRuntimeHealthBackgroundReportingIntervalAsync(TimeSpan, CancellationToken)

Change the interval at which this client will send background reports of the latest cached asset runtime healths

public Task SetRuntimeHealthBackgroundReportingIntervalAsync(TimeSpan reportingInterval, CancellationToken cancellationToken = default)

Parameters

reportingInterval TimeSpan

The new reporting interval

cancellationToken CancellationToken

Cancellation token

Returns

Task

Remarks

If background reporting is currently in progress, it will be cancelled and restarted with this new interval. If background reporting is not currently in progress, calling this method will not start it.