diff --git a/.gitignore b/.gitignore index a447135..894a44c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,104 @@ -build -*.pyc -dist -*.tar.gz -*.o -a.out +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions *.so -*.egg-info -.env -__pycache__ + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg MANIFEST -*.sublime-workspace -.envrc-extra + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/cystatsd/collector/collector.pyx b/cystatsd/collector/collector.pyx index 4beb8bd..a4ccfa5 100644 --- a/cystatsd/collector/collector.pyx +++ b/cystatsd/collector/collector.pyx @@ -21,29 +21,29 @@ cdef class MetricCollector: def __init__(self, int mtu=512): self.collector = CPPMetricCollector(mtu) - cpdef _push_timer(self, bytes name, int value, float rate): + cpdef _push_timer(self, bytes name, long long int value, float rate): self.collector.pushTimer(name, value, rate) - def push_timer(self, name, int value, float rate=1.0): + def push_timer(self, name, long long int value, float rate=1.0): if isinstance(name, UNICODE_TYPE): name = name.encode('utf-8') self._push_timer(name, value, rate) - cpdef _push_counter(self, bytes name, int value, float rate=1.0): + cpdef _push_counter(self, bytes name, long long int value, float rate=1.0): self.collector.pushCounter(name, value, rate) - def push_counter(self, name, int value, float rate=1.0): + def push_counter(self, name, long long int value, float rate=1.0): if isinstance(name, UNICODE_TYPE): name = name.encode('utf-8') self._push_counter(name, value, rate) - cpdef _push_gauge(self, bytes name, int value, float rate=1.0): + cpdef _push_gauge(self, bytes name, long long int value, float rate=1.0): self.collector.pushGauge(name, value, rate) - cpdef _push_gauge_delta(self, bytes name, int value, float rate=1.0): + cpdef _push_gauge_delta(self, bytes name, long long int value, float rate=1.0): self.collector.pushGaugeDelta(name, value, rate) - def push_gauge(self, name, int value, float rate=1.0, delta = False): + def push_gauge(self, name, long long int value, float rate=1.0, delta = False): if isinstance(name, UNICODE_TYPE): name = name.encode('utf-8') if delta: @@ -51,10 +51,10 @@ cdef class MetricCollector: else: self._push_gauge(name, value, rate) - cpdef _push_set(self, bytes name, int value, float rate=1.0): + cpdef _push_set(self, bytes name, long long int value, float rate=1.0): self.collector.pushSet(name, value, rate) - def push_set(self, name, int value, float rate=1.0): + def push_set(self, name, long long int value, float rate=1.0): if isinstance(name, UNICODE_TYPE): name = name.encode('utf-8') self._push_set(name, value, rate) diff --git a/cystatsd/collector/cstatsd_proto.pxd b/cystatsd/collector/cstatsd_proto.pxd index c4494fd..2ed7983 100644 --- a/cystatsd/collector/cstatsd_proto.pxd +++ b/cystatsd/collector/cstatsd_proto.pxd @@ -5,15 +5,15 @@ cdef extern from "./statsd_proto.hpp" namespace "statsd_proto": cdef cppclass MetricCollector: MetricCollector() MetricCollector(size_t) - void pushGauge(const string &name, int value) - void pushGaugeDelta(const string &name, int value) - void pushTimer(const string &name, int value) - void pushCounter(const string &name, int value) - void pushSet(const string &name, int value) - void pushGauge(const string &name, int value, float rate) - void pushGaugeDelta(const string &name, int value, float rate) - void pushTimer(const string &name, int value, float rate) - void pushCounter(const string &name, int value, float rate) - void pushSet(const string &name, int value, float rate) + void pushGauge(const string &name, long long int value) + void pushGaugeDelta(const string &name, long long int value) + void pushTimer(const string &name, long long int value) + void pushCounter(const string &name, long long int value) + void pushSet(const string &name, long long int value) + void pushGauge(const string &name, long long int value, float rate) + void pushGaugeDelta(const string &name, long long int value, float rate) + void pushTimer(const string &name, long long int value, float rate) + void pushCounter(const string &name, long long int value, float rate) + void pushSet(const string &name, long long int value, float rate) vector[string] flush() diff --git a/cystatsd/collector/statsd_proto.cpp b/cystatsd/collector/statsd_proto.cpp index dfd900a..79b14cc 100644 --- a/cystatsd/collector/statsd_proto.cpp +++ b/cystatsd/collector/statsd_proto.cpp @@ -44,7 +44,7 @@ const char* BufferHandle::data() const { Metric::Metric(){} -Metric::Metric(MetricType mtype, std::string name, int64_t val) +Metric::Metric(MetricType mtype, std::string name, long long int val) : metricType_(mtype), name_(name), value_(val) {} void Metric::encodeTo(BufferHandle *buff) { @@ -85,7 +85,7 @@ SampledMetric::SampledMetric(Metric met, float rate) : metric_(met), rate_(rate) {} SampledMetric::SampledMetric(MetricType mtype, - const string& name, int64_t value, float rate) + const string& name, long long int value, float rate) : metric_(mtype, name, value), rate_(rate) {} SampledMetric::SampledMetric() {} @@ -166,23 +166,23 @@ std::vector MetricCollector::flush() { return result; } -void MetricCollector::pushTimer(const string& name, int64_t val, float rate) { +void MetricCollector::pushTimer(const string& name, long long int val, float rate) { metrics_.emplace_back(MetricType::TIMER, name, val, rate); } -void MetricCollector::pushCounter(const string& name, int64_t val, float rate) { +void MetricCollector::pushCounter(const string& name, long long int val, float rate) { metrics_.emplace_back(MetricType::COUNTER, name, val, rate); } -void MetricCollector::pushGauge(const string& name, int64_t val, float rate) { +void MetricCollector::pushGauge(const string& name, long long int val, float rate) { metrics_.emplace_back(MetricType::GAUGE, name, val, rate); } -void MetricCollector::pushGaugeDelta(const string& name, int64_t val, float rate) { +void MetricCollector::pushGaugeDelta(const string& name, long long int val, float rate) { metrics_.emplace_back(MetricType::GAUGE_DELTA, name, val, rate); } -void MetricCollector::pushSet(const string& name, int64_t val, float rate) { +void MetricCollector::pushSet(const string& name, long long int val, float rate) { metrics_.emplace_back(MetricType::SET, name, val, rate); } diff --git a/cystatsd/collector/statsd_proto.hpp b/cystatsd/collector/statsd_proto.hpp index b8ff163..a5a6146 100644 --- a/cystatsd/collector/statsd_proto.hpp +++ b/cystatsd/collector/statsd_proto.hpp @@ -40,10 +40,10 @@ class Metric { protected: MetricType metricType_ {MetricType::NONE}; std::string name_ {""}; - int64_t value_ {0}; + long long int value_ {0}; public: Metric(); - Metric(MetricType mtype, std::string name, int64_t val); + Metric(MetricType mtype, std::string name, long long int val); void encodeTo(BufferHandle*); }; @@ -55,7 +55,7 @@ class SampledMetric { SampledMetric(); bool isSampled() const; SampledMetric(Metric met, float rate); - SampledMetric(MetricType met, const std::string &name, int64_t val, float rate); + SampledMetric(MetricType met, const std::string &name, long long int val, float rate); SampledMetric(Metric met); void encodeTo(BufferHandle*); }; @@ -70,11 +70,11 @@ class MetricCollector { size_t count() const; bool empty() const; std::vector flush(); - void pushTimer(const std::string& name, int64_t value, float rate = 1.0); - void pushCounter(const std::string& name, int64_t value, float rate = 1.0); - void pushGauge(const std::string& name, int64_t value, float rate = 1.0); - void pushGaugeDelta(const std::string& name, int64_t value, float rate = 1.0); - void pushSet(const std::string& name, int64_t value, float rate = 1.0); + void pushTimer(const std::string& name, long long int value, float rate = 1.0); + void pushCounter(const std::string& name, long long int value, float rate = 1.0); + void pushGauge(const std::string& name, long long int value, float rate = 1.0); + void pushGaugeDelta(const std::string& name, long long int value, float rate = 1.0); + void pushSet(const std::string& name, long long int value, float rate = 1.0); }; diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..4c7aa66 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +Cython==0.27.3 +nose==1.3.7