private function createMetricCollector(ContainerBuilder $container, $name, array $collector)
{
$serviceName = 'tolerance.metrics.collector.' . $name;
if ($collector['type'] == 'rabbitmq') {
$options = $collector['options'];
$httpClientServiceName = $serviceName . '.http_client';
$container->setDefinition($httpClientServiceName, new Definition(Client::class));
$clientServiceName = $serviceName . '.client';
$container->setDefinition($clientServiceName, new Definition(RabbitMqHttpClient::class, [new Reference($httpClientServiceName), $options['host'], $options['port'], $options['username'], $options['password']]));
$definition = $container->setDefinition($serviceName, new Definition(RabbitMqCollector::class, [new Reference($clientServiceName), $options['vhost'], $options['queue']]));
} else {
throw new \InvalidArgumentException(sprintf('Type "%s" not supported', $collector['type']));
}
if ($collector['namespace']) {
$container->setDefinition($serviceName . '.inner', $container->getDefinition($serviceName));
$definition = $container->setDefinition($serviceName, new Definition(NamespacedCollector::class, [new Reference($serviceName . '.inner'), $collector['namespace']]));
}
return $definition;
}