MetricsConfig class

Configuration options for telemetry and metrics collection.

Controls what metrics are gathered and how they're exported. Metrics can include system resources, network activity, and storage usage.

Example:

final config = MetricsConfig(
  enabled: true,
  collectionIntervalSeconds: 30,
  enablePrometheusExport: true,
  enableOpenTelemetry: true,
  otlpEndpoint: 'http://localhost:4318/v1/metrics',
);

Constructors

MetricsConfig({bool enabled = true, int collectionIntervalSeconds = 60, @Deprecated('System metrics collection is not implemented; ' 'this option is ignored.') bool collectSystemMetrics = true, bool collectNetworkMetrics = true, bool collectStorageMetrics = true, bool enablePrometheusExport = false, String prometheusEndpoint = '/metrics', bool enableOpenTelemetry = false, String otlpEndpoint = 'http://localhost:4318/v1/metrics', Map<String, String> otlpHeaders = const {}, int exportIntervalSeconds = 60})
Creates a metrics configuration with the given options. Creates a new MetricsConfig with the given collection options.
const
MetricsConfig.fromJson(Map<String, dynamic> json)
Creates a MetricsConfig from a JSON map.
factory

Properties

collectionIntervalSeconds → int
How often metrics are collected, in seconds.
final
collectNetworkMetrics → bool
Whether to collect network bandwidth and peer metrics.
final
collectStorageMetrics → bool
Whether to collect disk and block storage metrics.
final
collectSystemMetrics → bool
Whether to collect CPU and memory metrics.
final
enabled → bool
Whether metrics collection is enabled.
final
enableOpenTelemetry → bool
Whether to export metrics to an OpenTelemetry collector via OTLP/HTTP.
final
enablePrometheusExport → bool
Whether to expose metrics via Prometheus endpoint.
final
exportIntervalSeconds → int
How often metrics are pushed to otlpEndpoint, in seconds.
final
hashCode → int
The hash code for this object.
no setterinherited
otlpEndpoint → String
The OTLP/HTTP endpoint that receives ExportMetricsServiceRequest payloads, e.g. http://localhost:4318/v1/metrics.
final
otlpHeaders → Map<String, String>
Additional HTTP headers sent with every OTLP export request.
final
prometheusEndpoint → String
The HTTP path for Prometheus metrics.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts this configuration to a JSON map.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited