-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add monotonic counter uint meter type (#105)
This change is a companion to the fix for monotonic counter implementations in spectatord. Netflix-Skunkworks/spectatord#90 The original monotonic counter (`C`) was always intended to be used for the case where a monotonic data source needs to be transformed into base units for recording data. For example, transforming nanoseconds into seconds. This requires division, which results in floats. There is a valid use case for handling uints in monotonic counters, if the data source is already in a base unit, such as bytes. Thus, a new meter type `U` is added to spectatord which supports this use case.
- Loading branch information
1 parent
b3b93d6
commit 0b4efd6
Showing
12 changed files
with
350 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.DS_Store | ||
.idea/ | ||
cmake-build-debug/ | ||
cmake-build-debug | ||
cmake-build/ | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
conan==1.62.0 | ||
conan==1.64.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
PYTHON3=$(which python3) | ||
MAYBE_PYTHON=$(find /apps -maxdepth 1 -type l -name "python*") | ||
|
||
if [[ -z $PYTHON3 ]]; then | ||
echo "python3 is not available - please install" | ||
exit 1 | ||
if [[ -n "$MAYBE_PYTHON" ]]; then | ||
PYTHON3="$MAYBE_PYTHON/bin/python3" | ||
echo "using $PYTHON3 ($($PYTHON3 -V))" | ||
else | ||
PYTHON3="python3" | ||
echo "using $(which $PYTHON3) ($($PYTHON3 -V))" | ||
fi | ||
|
||
python3 -m venv venv | ||
|
||
# create and activate virtualenv | ||
$PYTHON3 -m venv venv | ||
source venv/bin/activate | ||
|
||
if [[ -f requirements.txt ]]; then | ||
pip3 install --upgrade pip wheel | ||
pip3 install --requirement requirements.txt | ||
# use the virtualenv python | ||
python -m pip install --upgrade pip wheel | ||
python -m pip install --requirement requirements.txt | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "stateless_meters.h" | ||
#include "test_publisher.h" | ||
#include <gtest/gtest.h> | ||
|
||
namespace { | ||
|
||
using spectator::Id; | ||
using spectator::MonotonicCounterUint; | ||
using spectator::Tags; | ||
using spectator::TestPublisher; | ||
|
||
TEST(MonotonicCounterUint, Set) { | ||
TestPublisher publisher; | ||
auto id = std::make_shared<Id>("ctr", Tags{}); | ||
auto id2 = std::make_shared<Id>("ctr2", Tags{{"key", "val"}}); | ||
MonotonicCounterUint<TestPublisher> c{id, &publisher}; | ||
MonotonicCounterUint<TestPublisher> c2{id2, &publisher}; | ||
|
||
c.Set(42); | ||
c2.Set(2); | ||
c.Set(43); | ||
std::vector<std::string> expected = {"U:ctr:42", "U:ctr2,key=val:2", "U:ctr:43"}; | ||
EXPECT_EQ(publisher.SentMessages(), expected); | ||
} | ||
} // namespace |
Oops, something went wrong.