Skip to content

Commit b324ac7

Browse files
committed
update to 0.0.6
* Add support for Spare Data Strategy and Unit settings for Metrics * Prevent duplicate metrics * Documentation improvements
1 parent ab02937 commit b324ac7

7 files changed

Lines changed: 53 additions & 6 deletions

File tree

HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
History
44
-------
55

6+
0.0.6 (2015-06-23)
7+
---------------------
8+
9+
* Add support for Spare Data Strategy and Unit settings for Metrics
10+
* Prevent duplicate metrics
11+
* Documentation improvements
12+
13+
614
0.0.5 (2015-06-12)
715
---------------------
816

README.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Usage
3131
* Add a Metric Sample
3232
``MyElement.add_sample('cpu.idle', 1432832135, 1, host='my_hostname')``
3333

34+
* Add a Metric Sample with a Sparse Data Strategy
35+
``MyElement.add_sample('app.zero', 1432832135, 1, host='my_hostname', sparseDataStrategy='ReplaceWithZero')``
36+
37+
* Add a Metric Sample with unit type
38+
``MyElement.add_sample('app.requests', 1432832135, 1, host='my_hostname', unit='requests/s')``
39+
40+
3441
* Send the Samples
3542
``ApiClient.post(MyElement)``
3643

@@ -43,7 +50,7 @@ Example
4350

4451
import netuitive
4552

46-
ApiClient = netuitive.Client(apikey='aaaa9956110211e594931697f925ec7b')
53+
ApiClient = netuitive.Client(apikey='aaaa9956110211e594444697f922ec7b')
4754

4855
MyElement = netuitive.Element()
4956

netuitive/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
__author__ = 'Netuitive, Inc'
4-
__version__ = '0.0.3'
4+
__version__ = '0.0.6'
55

66
from .client import Client
77
from .element import Element

netuitive/element.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def add_tag(self, name, value):
2424
self.tags.append(Tag(name, value))
2525

2626
def add_sample(self, metricId, timestamp, value,
27-
metricType=None, host=None):
27+
metricType=None, host=None, sparseDataStrategy='None', unit=''):
2828
"""
2929
add a metric sample
3030
"""
3131

3232
self.id = host
3333
self.name = host
34-
metric = Metric(metricId, metricType)
34+
metric = Metric(metricId, metricType, sparseDataStrategy, unit)
3535

3636
if len(self.metrics) > 0:
3737
for m in self.metrics:

netuitive/metric.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class Metric(object):
99
1010
"""
1111

12-
def __init__(self, metricId, metricType=None):
12+
def __init__(self, metricId, metricType=None, sparseDataStrategy='None', unit=''):
1313
self.id = metricId
1414
self.type = metricType
15+
self.sparseDataStrategy = sparseDataStrategy
16+
self.unit = unit

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
setup(
2626
name='netuitive',
27-
version='0.0.5',
27+
version='0.0.6',
2828
description="Python Client for Netuitive Cloud.",
2929
long_description=readme + '\n\n' + history,
3030
author="Netuitive",

tests/test_netuitive.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,36 @@ def test(self):
9999
self.failUnlessEqual(a.samples[0].timestamp, 1434110794000)
100100
self.failUnlessEqual(a.samples[0].val, 1)
101101

102+
# test clear_samples
103+
self.failUnlessEqual(len(a.metrics), 1)
104+
a.clear_samples()
105+
self.failUnlessEqual(len(a.metrics), 0)
106+
self.failUnlessEqual(len(a.samples), 0)
107+
108+
# test sparseDataStrategy
109+
a.add_sample(
110+
'nonsparseDataStrategy', 1434110794, 1, 'COUNTER', host='hostname')
111+
a.add_sample(
112+
'sparseDataStrategy', 1434110794, 1, 'COUNTER', host='hostname', sparseDataStrategy='ReplaceWithZero')
113+
114+
self.failUnlessEqual(a.metrics[0].sparseDataStrategy, 'None')
115+
self.failUnlessEqual(
116+
a.metrics[1].sparseDataStrategy, 'ReplaceWithZero')
117+
118+
a.clear_samples()
119+
120+
# test unit
121+
a.add_sample(
122+
'unit', 1434110794, 1, 'COUNTER', host='hostname', unit='Bytes')
123+
124+
a.add_sample(
125+
'nonunit', 1434110794, 1, 'COUNTER', host='hostname')
126+
127+
self.failUnlessEqual(
128+
a.metrics[0].unit, 'Bytes')
129+
130+
self.failUnlessEqual(a.metrics[1].unit, '')
131+
102132
def tearDown(self):
103133
pass
104134

0 commit comments

Comments
 (0)