Skip to content

Commit

Permalink
getter for BatchedDogStatsd::$bufferLength
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech committed Jul 10, 2024
1 parent 0efdd1c commit 33793aa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/BatchedDogStatsd.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ public function flushBuffer()
static::$buffer = array();
static::$bufferLength = 0;
}

/**
* @return int
*/
public static function getBufferLength()
{
return self::$bufferLength;
}
}
22 changes: 22 additions & 0 deletions tests/UnitTests/BatchedDogStatsdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,26 @@ public function testReportSendsOnceBufferIsFilled()
array("metrics" => 3)
);
}

public function testGetBufferLength() {
$batchedDog = new BatchedDogStatsd();

$this->assertEquals(0, BatchedDogStatsd::getBufferLength());

$batchedDog->gauge("some-value", 1);

$this->assertEquals(1, BatchedDogStatsd::getBufferLength());
}

public function testGetBufferLengthAfterExceedingMaxBufferLength()
{
BatchedDogStatsd::$maxBufferLength = 2;

$batchedDog = new BatchedDogStatsd();

$batchedDog->increment(["first-value", "another-value", "yet-another-value"]);
$batchedDog->gauge("some-value", 1);

$this->assertEquals(1, BatchedDogStatsd::getBufferLength());
}
}

0 comments on commit 33793aa

Please sign in to comment.