Table of Contents

Class ResourceMetricsService

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Background service that periodically updates resource snapshots and raises alerts.

public sealed class ResourceMetricsService : IDisposable
Inheritance
ResourceMetricsService
Implements
Inherited Members

Remarks

This service is timer-based and does not depend on ASP.NET Core's IHostedService. It can be used in any .NET application.

Operation:

var service = new ResourceMetricsService(exporter, healthChecker, alertGenerator, options);
service.AlertRaised += (sender, alert) =>
{
    Console.WriteLine($"Alert: {alert.Title}");
};
service.Start();

// Later...
service.Stop();
service.Dispose();

Constructors

ResourceMetricsService(ResourceMetricsExporter, ResourceHealthChecker, ResourceAlertGenerator, ObservabilityBridgeOptions)

Creates a new ResourceMetricsService.

public ResourceMetricsService(ResourceMetricsExporter exporter, ResourceHealthChecker healthChecker, ResourceAlertGenerator alertGenerator, ObservabilityBridgeOptions options)

Parameters

exporter ResourceMetricsExporter

The metrics exporter.

healthChecker ResourceHealthChecker

The health checker.

alertGenerator ResourceAlertGenerator

The alert generator.

options ObservabilityBridgeOptions

Configuration options.

Properties

CurrentStatus

The current health status from the last check.

public HealthStatus CurrentStatus { get; }

Property Value

HealthStatus

IsRunning

Whether the service is currently running.

public bool IsRunning { get; }

Property Value

bool

Methods

Dispose()

Disposes the timer and stops the service.

public void Dispose()

ForceUpdate()

Force an immediate snapshot update and health check.

public HealthStatus ForceUpdate()

Returns

HealthStatus

The current health status.

Start()

Start the background refresh service.

public void Start()

Stop()

Stop the background refresh service.

public void Stop()

Events

AlertRaised

Event raised when a resource crosses health thresholds.

public event EventHandler<ResourceAlert> AlertRaised

Event Type

EventHandler<ResourceAlert>

Remarks

Alerts are only raised on state transitions to avoid flooding:

  • Healthy → Degraded: Warning alert
  • Healthy → Unhealthy: Critical alert
  • Degraded → Unhealthy: Critical alert (escalation)

No alert is raised when recovering (Unhealthy → Degraded → Healthy).

HealthStatusChanged

Event raised when health status changes (including recovery).

public event EventHandler<HealthStatusChangedEventArgs> HealthStatusChanged

Event Type

EventHandler<HealthStatusChangedEventArgs>