Skip to content

Commit e2902cd

Browse files
committed
query_raw_data
1 parent bc85d43 commit e2902cd

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

source/opentsdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def build_collector(self, jreq: dict) -> SensorCollector:
163163
if 'arrays' in jreq:
164164
args['dpsArrays'] = jreq['arrays']
165165

166-
args['rawData'] = q.get('explicitTags', False)
166+
args['rawData'] = q.get('explicitTags', False) or q.get('isCounter', False)
167167

168168
args['sensor'] = sensor
169169
args['period'] = period

tests/test_opentsdb.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,40 @@ def query_arrays_setup():
103103
}
104104
}
105105

106+
def query_raw_data_setup():
107+
global jreq, jreq1, jreq2, jreq3
108+
109+
jreq = {'start': 1739214930519, 'end': 1739215230519, 'arrays': True,
110+
'inputQuery': {'aggregator': 'noop', 'downsample': '1m-avg',
111+
'filters': [
112+
{'filter': 'scale-11', 'groupBy': False,
113+
'tagk': 'node', 'type': 'pm_filter'
114+
}],
115+
'metric': 'cpu_system', 'index': 0,
116+
'shouldComputeRate': False, 'isCounter': False
117+
}
118+
}
119+
jreq1 = {'start': 1739214930519, 'end': 1739215230519, 'arrays': True,
120+
'inputQuery': {'aggregator': 'noop', 'downsample': '1m-avg',
121+
'filters': [
122+
{'filter': 'scale-11', 'groupBy': False,
123+
'tagk': 'node', 'type': 'pm_filter'
124+
}],
125+
'metric': 'cpu_system', 'index': 0,
126+
'shouldComputeRate': True, 'isCounter': False
127+
}
128+
}
129+
jreq2 = {'start': 1739214930519, 'end': 1739215230519, 'arrays': True,
130+
'inputQuery': {'aggregator': 'noop', 'downsample': '1m-avg',
131+
'filters': [
132+
{'filter': 'scale-11', 'groupBy': False,
133+
'tagk': 'node', 'type': 'pm_filter'
134+
}],
135+
'metric': 'cpu_system', 'index': 0,
136+
'shouldComputeRate': True, 'isCounter': True
137+
}
138+
}
139+
106140

107141
@with_setup(my_setup)
108142
def test_case01():
@@ -195,3 +229,19 @@ def test_case07():
195229
assert 'node' in resp[0].get('tags')
196230
assert isinstance(resp[0].get('dps'), list)
197231
assert len(resp[0].get('dps')) == 0
232+
233+
234+
@with_setup(query_raw_data_setup)
235+
def test_case08():
236+
q = jreq.get('inputQuery')
237+
args = {}
238+
args['rawData'] = q.get('explicitTags', False) or q.get('isCounter', False)
239+
assert args.get('rawData') == False
240+
q1 = jreq1.get('inputQuery')
241+
args1 = {}
242+
args1['rawData'] = q1.get('explicitTags', False) or q1.get('isCounter', False)
243+
assert args1.get('rawData') == False
244+
q2 = jreq2.get('inputQuery')
245+
args2 = {}
246+
args2['rawData'] = q2.get('explicitTags', False) or q2.get('isCounter', False)
247+
assert args2.get('rawData') == True

0 commit comments

Comments
 (0)