metrics method

  1. @override
Future metrics({
  1. Map<String, String>? globalLabels,
  2. required MetricsFormat format,
})
override

Returns the metrics for the engine.

Implementation

@override
Future metrics({
  Map<String, String>? globalLabels,
  required MetricsFormat format,
}) async {
  await start();

  final response = await fetch(
    _endpoint.replace(
      path: '/metrics',
      queryParameters: {'format': format.name},
    ),
    method: 'POST',
    body: globalLabels,
  );

  return switch (format) {
    MetricsFormat.json => response.json(),
    MetricsFormat.prometheus => response.text(),
  };
}