コード例 #1
0
 /**
  * Tests batch of messages handle
  */
 public function testHandleBatch()
 {
     $handler = new UdpHandler($this->testHost, $this->testPort, $this->testTimeout);
     $handler->setFactory($this->mockFactory);
     // Normal messages
     $batch1 = [new CounterMetric('metric_name_batch1', 1), new CounterMetric('metric_name_batch2', 2), new CounterMetric('metric_name_batch3', 3), new CounterMetric('metric_name_batch4', 4)];
     $expectedMessages = self::$formatter->formatBatch($batch1);
     $this->mockSocket->shouldReceive('write')->withArgs([join("\n", $expectedMessages)])->once();
     $handler->handleBatch($batch1);
 }
コード例 #2
0
 /**
  * Tests sampling
  */
 public function testMetricSample()
 {
     $metric1 = new CounterMetric('metric_name1', 10);
     $metric1->setSampleRate(0.2);
     $expected1 = 'metric_name1 value=' . 10 * 0.2;
     $this->assertEquals($expected1, $this->formatter->format($metric1));
 }
コード例 #3
0
 /**
  * @iterations 1000
  */
 public function counterNameTagsAndSample()
 {
     $this->formatter->format($this->metricTagsSample);
 }