Ejemplo n.º 1
0
 /**
  * Tests batch of messages handle
  */
 public function testHandleBatchExceedMtu()
 {
     $handler = new StatsDaemonHandler($this->testHost, $this->testPort, $this->testTimeout, 'udp', 50);
     $handler->setFactory($this->mockFactory);
     // Normal messages
     $batch1 = [new CounterMetric(str_repeat('a', 18), 1), new CounterMetric(str_repeat('b', 18), 2), new CounterMetric(str_repeat('c', 18), 3)];
     $expectedMessages = self::$formatter->formatBatch($batch1);
     $this->mockSocket->shouldReceive('write')->withArgs([$expectedMessages[0] . "\n" . $expectedMessages[1]])->once();
     $this->mockSocket->shouldReceive('write')->withArgs([$expectedMessages[2]])->once();
     $handler->handleBatch($batch1);
 }
 /**
  * Tests batch formatting
  */
 public function testBatchFormatter()
 {
     $metrics = [new CounterMetric('counter_metric', 10), new MemoryMetric('memory_metric', 20), new TimerMetric('timer_metric', 30), new GaugeMetric('gauge_metric', 40), new UniqueMetric('unique_metric', 50), new UniqueMetric('false_metric', ['internal' => 10])];
     $expected = ['counter_metric:10|c', 'memory_metric:20|c', 'timer_metric:30|ms', 'gauge_metric:40|g', 'unique_metric:50|s'];
     $this->assertEquals($expected, $this->formatter->formatBatch($metrics));
 }
Ejemplo n.º 3
0
 /**
  * @iterations 1000
  */
 public function counterNameTagsAndSample()
 {
     $this->formatter->format($this->metricTagsSample);
 }