MetricsConfig.fromJson constructor

MetricsConfig.fromJson(
  1. Map<String, dynamic> json
)

Creates a MetricsConfig from a JSON map.

Implementation

factory MetricsConfig.fromJson(Map<String, dynamic> json) {
  return MetricsConfig(
    enabled: json['enabled'] as bool? ?? true,
    collectionIntervalSeconds:
        json['collectionIntervalSeconds'] as int? ?? 60,
    // ignore: deprecated_member_use_from_same_package
    collectSystemMetrics: json['collectSystemMetrics'] as bool? ?? true,
    collectNetworkMetrics: json['collectNetworkMetrics'] as bool? ?? true,
    collectStorageMetrics: json['collectStorageMetrics'] as bool? ?? true,
    enablePrometheusExport: json['enablePrometheusExport'] as bool? ?? false,
    prometheusEndpoint: json['prometheusEndpoint'] as String? ?? '/metrics',
    enableOpenTelemetry: json['enableOpenTelemetry'] as bool? ?? false,
    otlpEndpoint:
        json['otlpEndpoint'] as String? ?? 'http://localhost:4318/v1/metrics',
    otlpHeaders:
        (json['otlpHeaders'] as Map?)?.cast<String, String>() ?? const {},
    exportIntervalSeconds: json['exportIntervalSeconds'] as int? ?? 60,
  );
}