open method
Opens the component.
correlationId
(optional) transaction id to trace execution through call chain. Return Future that receives null no errors occured. Throws error
Implementation
@override
Future open(String? correlationId) async {
if (_opened) {
return null;
}
if (!_pushEnabled) {
return null;
}
ConfigParams? connection;
try {
connection = await _connectionResolver.resolve(correlationId);
if (connection == null) {
throw Exception('Empty config.');
}
} catch (err) {
_client = null;
_logger.warn(
correlationId,
'Connection to Prometheus server is not configured: ' +
err.toString());
return null;
}
var job = _source ?? 'unknown';
var instance = _instance ?? Platform.localHostname;
_requestRoute = '/metrics/job/' + job + '/instance/' + instance;
_uri = connection.getAsString('uri');
_client = http.Client();
_opened = true;
}