Skip to main content

Monitoring Utils API Reference

The Monitoring Utils provide comprehensive monitoring, logging, and observability features for edge applications.

MetricsCollector

Metrics collection and reporting.

Constructor

Parameters:
  • options (object): Metrics configuration options

Methods

counter(name, labels)

Create or get counter metric.
Parameters:
  • name (string): Metric name
  • labels (object, optional): Metric labels
Returns: Counter instance

gauge(name, labels)

Create or get gauge metric.
Parameters:
  • name (string): Metric name
  • labels (object, optional): Metric labels
Returns: Gauge instance

histogram(name, labels)

Create or get histogram metric.
Parameters:
  • name (string): Metric name
  • labels (object, optional): Metric labels
Returns: Histogram instance

send(name, value, labels)

Send custom metric.
Parameters:
  • name (string): Metric name
  • value (number): Metric value
  • labels (object, optional): Metric labels

StructuredLogger

Structured logging utilities.

Constructor

Parameters:
  • options (object): Logger configuration options

Methods

info(message, context)

Log info level message.
Parameters:
  • message (string): Log message
  • context (object, optional): Additional context

error(message, error, context)

Log error level message.
Parameters:
  • message (string): Log message
  • error (Error, optional): Error object
  • context (object, optional): Additional context

warn(message, context)

Log warning level message.
Parameters:
  • message (string): Log message
  • context (object, optional): Additional context

debug(message, context)

Log debug level message.
Parameters:
  • message (string): Log message
  • context (object, optional): Additional context

DistributedTracer

Distributed tracing utilities.

Constructor

Parameters:
  • options (object): Tracing configuration options

Methods

startSpan(name, parent)

Start a new trace span.
Parameters:
  • name (string): Span name
  • parent (Span, optional): Parent span
Returns: Span instance

inject(span, carrier)

Inject trace context into carrier.
Parameters:
  • span (Span): Trace span
  • carrier (object): Context carrier

extract(carrier)

Extract trace context from carrier.
Parameters:
  • carrier (object): Context carrier
Returns: Span context

HealthChecker

Application health checking.

Constructor

Parameters:
  • options (object): Health check configuration

Methods

addCheck(name, checkFn)

Add health check.
Parameters:
  • name (string): Check name
  • checkFn (function): Health check function

runChecks()

Run all health checks.
Returns: Promise resolving to health check results

getStatus()

Get overall health status.
Returns: Health status (‘healthy’, ‘unhealthy’, ‘degraded’)

Type Definitions

MetricOptions

LogContext

Span

HealthCheckResult