Skip to content

Commit

Permalink
librato: drop integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Feb 29, 2024
1 parent 146c52b commit 954311d
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 154 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Currently supported backends:
* Graphite
* InfluxDB
* Telegraf
* Librato
* Logger (Psr\Log\LoggerInterface)
* Null (Dummy that does nothing)
* Prometheus
Expand Down Expand Up @@ -70,12 +69,6 @@ $collector->flush();
<?php
$statsd = \Beberlei\Metrics\Factory::create('statsd');

$librato = \Beberlei\Metrics\Factory::create('librato', array(
'hostname' => 'foo.beberlei.de',
'username' => 'foo',
'password' => 'bar',
));

$null = \Beberlei\Metrics\Factory::create('null');
```

Expand Down Expand Up @@ -106,11 +99,6 @@ beberlei_metrics:
collectors:
foo:
type: statsd
librato:
type: librato
username: foo
password: bar
source: hermes10
dbal:
type: doctrine_dbal
connection: metrics # using the connection named "metrics"
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"jimdo/prometheus_client_php": "^0.5.1",
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/http-client": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"symfony/phpunit-bridge": "^6.4.4 || ^7.0"
},
Expand All @@ -50,7 +49,6 @@
},
"suggest": {
"corley/influxdb-sdk": "For InfluxDB integration",
"kriswallsmith/buzz": "For Librato integration",
"jimdo/prometheus_client_php": "For Prometheus integration"
},
"config": {
Expand Down
66 changes: 0 additions & 66 deletions src/Metrics/Collector/Librato.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/Metrics/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Beberlei\Metrics\Collector\DogStatsD;
use Beberlei\Metrics\Collector\Graphite;
use Beberlei\Metrics\Collector\InfluxDB;
use Beberlei\Metrics\Collector\Librato;
use Beberlei\Metrics\Collector\Logger;
use Beberlei\Metrics\Collector\NullCollector;
use Beberlei\Metrics\Collector\Prometheus;
Expand Down Expand Up @@ -115,21 +114,6 @@ public static function create(string $type, array $options = []): CollectorInter

return new Graphite($options['host'], $options['port']);

case 'librato':
if (!isset($options['hostname'])) {
throw new MetricsException('Hostname is required for librato collector.');
}

if (!isset($options['username'])) {
throw new MetricsException('No username given for librato collector.');
}

if (!isset($options['password'])) {
throw new MetricsException('No password given for librato collector.');
}

return new Librato(self::getHttpClient(), $options['hostname'], $options['username'], $options['password']);

case 'doctrine_dbal':
if (!isset($options['connection'])) {
throw new MetricsException('connection is required for Doctrine DBAL collector.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ private function createCollector(string $type, array $config): ChildDefinition
case 'influxdb':
$definition->replaceArgument(0, new Reference($config['influxdb_client']));

return $definition;
case 'librato':
$definition->replaceArgument(1, $config['host']);
$definition->replaceArgument(2, $config['username']);
$definition->replaceArgument(3, $config['password']);

return $definition;
case 'logger':
case 'null':
Expand Down
12 changes: 0 additions & 12 deletions src/MetricsBundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->prototype('scalar')->end()
->end()
->end()
->validate()
->ifTrue(static fn ($v): bool => 'librato' === $v['type'] && empty($v['host']))
->thenInvalid('The host has to be specified to use a Librato')
->end()
->validate()
->ifTrue(static fn ($v): bool => 'librato' === $v['type'] && empty($v['username']))
->thenInvalid('The username has to be specified to use a Librato')
->end()
->validate()
->ifTrue(static fn ($v): bool => 'librato' === $v['type'] && empty($v['password']))
->thenInvalid('The password has to be specified to use a Librato')
->end()
->validate()
->ifTrue(static fn ($v): bool => 'prometheus' === $v['type'] && empty($v['prometheus_collector_registry']))
->thenInvalid('The prometheus_collector_registry has to be specified to use a Prometheus')
Expand Down
11 changes: 0 additions & 11 deletions src/MetricsBundle/Resources/config/metrics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<!-- Util -->
<service id="beberlei_metrics.util.http_client" class="Symfony\Contracts\HttpClient\HttpClientInterface" public="false">
<factory class="Symfony\Component\HttpClient\HttpClient" method="create" />
</service>

<!-- Prototype / Collector -->
<service id="beberlei_metrics.collector_proto.doctrine_dbal" class="Beberlei\Metrics\Collector\DoctrineDBAL" abstract="true">
<argument /> <!-- Doctrine DBAL connection, set by the extension -->
Expand All @@ -22,12 +17,6 @@
<service id="beberlei_metrics.collector_proto.influxdb" class="Beberlei\Metrics\Collector\InfluxDB" abstract="true">
<argument /> <!-- InfluxDB client, set by the extension -->
</service>
<service id="beberlei_metrics.collector_proto.librato" class="Beberlei\Metrics\Collector\Librato" abstract="true">
<argument type="service" id="beberlei_metrics.util.http_client" />
<argument /> <!-- host, set by the extension -->
<argument /> <!-- port, set by the extension -->
<argument /> <!-- protocol, set by the extension -->
</service>
<service id="beberlei_metrics.collector_proto.logger" class="Beberlei\Metrics\Collector\Logger" abstract="true">
<argument type="service" id="logger" />
<tag name="monolog.logger" channel="beberlei_metrics" />
Expand Down
5 changes: 0 additions & 5 deletions tests/Metrics/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Beberlei\Metrics\Collector\DogStatsD;
use Beberlei\Metrics\Collector\Graphite;
use Beberlei\Metrics\Collector\InfluxDB;
use Beberlei\Metrics\Collector\Librato;
use Beberlei\Metrics\Collector\Logger;
use Beberlei\Metrics\Collector\NullCollector;
use Beberlei\Metrics\Collector\Prometheus;
Expand All @@ -33,7 +32,6 @@ public function getCreateValidMetricTests(): iterable
yield [DogStatsD::class, 'dogstatsd', ['host' => 'localhost']];
yield [Graphite::class, 'graphite'];
yield [Graphite::class, 'graphite', ['host' => 'localhost', 'port' => 1234]];
yield [Librato::class, 'librato', ['hostname' => 'foobar.com', 'username' => 'username', 'password' => 'password']];
yield [DoctrineDBAL::class, 'doctrine_dbal', ['connection' => $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock()]];
yield [Logger::class, 'logger', ['logger' => new NullLogger()]];
yield [NullCollector::class, 'null'];
Expand Down Expand Up @@ -61,9 +59,6 @@ public function getCreateThrowExceptionIfOptionsAreInvalidTests(): iterable
yield ['You should specified a host and a port if you specified a prefix.', 'dogstatsd', ['port' => '1234', 'prefix' => 'prefix']];
yield ['You should specified a host and a port if you specified a prefix.', 'dogstatsd', ['hostname' => 'foobar.com', 'prefix' => 'prefix']];
yield ['You should specified a host if you specified a port.', 'graphite', ['port' => '1234']];
yield ['Hostname is required for librato collector.', 'librato'];
yield ['No username given for librato collector.', 'librato', ['hostname' => 'foobar.com']];
yield ['No password given for librato collector.', 'librato', ['hostname' => 'foobar.com', 'username' => 'username']];
yield ['connection is required for Doctrine DBAL collector.', 'doctrine_dbal'];
yield ["Missing 'logger' key with logger service.", 'logger'];
yield ["Missing 'client' key for InfluxDB collector.", 'influxdb'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Beberlei\Metrics\Collector\Graphite;
use Beberlei\Metrics\Collector\InfluxDB;
use Beberlei\Metrics\Collector\InMemory;
use Beberlei\Metrics\Collector\Librato;
use Beberlei\Metrics\Collector\Logger;
use Beberlei\Metrics\Collector\NullCollector;
use Beberlei\Metrics\Collector\Prometheus;
Expand Down Expand Up @@ -51,29 +50,6 @@ public function testWithGraphite(): void
$this->assertSame(1234, $this->getProperty($collector, 'port'));
}

/**
* The source has to be specified to use a Librato.
*/
public function testWithLibratoAndInvalidConfiguration(): void
{
$this->expectException(InvalidConfigurationException::class);

$container = $this->createContainer(['collectors' => ['simple' => ['type' => 'librato']]], ['beberlei_metrics.collector.librato']);

$this->assertInstanceOf(Librato::class, $container->get('beberlei_metrics.collector.librato'));
}

public function testWithLibrato(): void
{
$container = $this->createContainer(['collectors' => ['full' => ['type' => 'librato', 'source' => 'foo.beberlei.de', 'username' => 'foo', 'password' => 'bar']]], ['beberlei_metrics.collector.full']);

$collector = $container->get('beberlei_metrics.collector.full');
$this->assertInstanceOf(Librato::class, $collector);
$this->assertSame('foo.beberlei.de', $this->getProperty($collector, 'source'));
$this->assertSame('foo', $this->getProperty($collector, 'username'));
$this->assertSame('bar', $this->getProperty($collector, 'password'));
}

public function testWithLogger(): void
{
$container = $this->createContainer(['collectors' => ['logger' => ['type' => 'logger']]], ['beberlei_metrics.collector.logger']);
Expand Down

0 comments on commit 954311d

Please sign in to comment.