Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

unsupported stat tweak

  • Loading branch information...
commit 65eb8f9a01008dca40bfa6599e47b19bf9e62e7b 1 parent 2bd4cf7
@esedor esedor authored
View
96 README.md
@@ -216,10 +216,10 @@ query as identified by 'queryMask'. Each report includes:
* queryMask - The query pattern, with values masked ($query for query component, $orderby for sort component)
* namespace - The MongoDB namespace in which to create the index,
in the form "db.collection"
-* details - specific query details aggregated from each query occurrence.
-* details.count - The total number of queries that occurred.
-* details.avgTimeMillis - The average time this query currently takes.
-* details.totalTimeMillis - The sum amount of time consumed by all of the queries that
+* stats - specific query statistics aggregated from each query occurrence.
+* stats.count - The total number of queries that occurred.
+* stats.avgTimeMillis - The average time this query currently takes.
+* stats.totalTimeMillis - The sum amount of time consumed by all of the queries that
match the queryMask.
* recommendation - A fully-formed recommendation object.
* recommendation.index - The index recommended.
@@ -229,93 +229,7 @@ the MongoDB shell.
Sample:
```
-{
- 'runStats': {
- 'linesWithRecommendations': 12,
- 'linesAnalyzed': 16,
- 'linesRead': 22,
- 'timeRange': {
- 'start': {
- '$date': 1375167617000
- },
- 'end': {
- '$date': 1375227086000
- }
- }
- },
- 'results': [
- {
- 'queryMask': '{"$orderby":{"classes":1,"level":1},"$query":{"classes":"<val>","level":{"$gte":"<val>"},"name":"<val>"}}',
- 'namespace': 'mongoquest.adventurers',
- 'recommendation': {
- 'index': '{"name": 1, "classes": 1, "level": 1}',
- 'namespace': 'mongoquest.adventurers',
- 'shellCommand': 'db["adventurers"].ensureIndex({"name": 1, "classes": 1, "level": 1}, {"background": true})'
- },
- 'details': {
- 'count': 4,
- 'totalTimeMillis': 809,
- 'avgTimeMillis': 202
- }
- },
- {
- 'queryMask': '{"$query":{"name":"<val>"}}',
- 'namespace': 'mongoquest.adventurers',
- 'recommendation': {
- 'index': '{"name": 1}',
- 'namespace': 'mongoquest.adventurers',
- 'shellCommand': 'db["adventurers"].ensureIndex({"name": 1}, {"background": true})'
- },
- 'details': {
- 'count': 2,
- 'totalTimeMillis': 476,
- 'avgTimeMillis': 238
- }
- },
- {
- 'queryMask': '{"$query":{"classes":"<val>"}}',
- 'namespace': 'mongoquest.adventurers',
- 'recommendation': {
- 'index': '{"classes": 1}',
- 'namespace': 'mongoquest.adventurers',
- 'shellCommand': 'db["adventurers"].ensureIndex({"classes": 1}, {"background": true})'
- },
- 'details': {
- 'count': 2,
- 'totalTimeMillis': 438,
- 'avgTimeMillis': 219
- }
- },
- {
- 'queryMask': '{"$orderby":{"classes":1,"level":1},"$query":{"classes":"<val>","level":"<val>","name":"<val>"}}',
- 'namespace': 'mongoquest.adventurers',
- 'recommendation': {
- 'index': '{"name": 1, "classes": 1, "level": 1}',
- 'namespace': 'mongoquest.adventurers',
- 'shellCommand': 'db["adventurers"].ensureIndex({"name": 1, "classes": 1, "level": 1}, {"background": true})'
- },
- 'details': {
- 'count': 2,
- 'totalTimeMillis': 401,
- 'avgTimeMillis': 200
- }
- },
- {
- 'queryMask': '{"$query":{"level":{"$gte":"<val>"}}}',
- 'namespace': 'mongoquest.adventurers',
- 'recommendation': {
- 'index': '{"level": 1}',
- 'namespace': 'mongoquest.adventurers',
- 'shellCommand': 'db["adventurers"].ensureIndex({"level": 1}, {"background": true})'
- },
- 'details': {
- 'count': 2,
- 'totalTimeMillis': 326,
- 'avgTimeMillis': 163
- }
- }
- ]
-}
+
```
#### Watch Mode Output to STDERR
View
14 dex/analyzer.py
@@ -337,15 +337,15 @@ def add_query_occurrence(self, report):
('supported', report['queryAnalysis']['supported']),
('indexStatus', report['indexStatus']),
('recommendation', report['recommendation']),
- ('details', OrderedDict([('count', 1),
- ('totalTimeMillis', initial_millis),
- ('avgTimeMillis', initial_millis)]))]))
+ ('stats', OrderedDict([('count', 1),
+ ('totalTimeMillis', initial_millis),
+ ('avgTimeMillis', initial_millis)]))]))
############################################################################
def get_reports(self):
"""Returns a minimized version of the aggregation"""
return sorted(self._reports,
- key=lambda x: x['details']['totalTimeMillis'],
+ key=lambda x: x['stats']['totalTimeMillis'],
reverse=True)
############################################################################
@@ -361,6 +361,6 @@ def _get_existing_report(self, mask, report):
def _merge_report(self, target, new):
"""Merges a new report into the target report"""
query_millis = int(new['parsed']['stats']['millis'])
- target['details']['totalTimeMillis'] += query_millis
- target['details']['count'] += 1
- target['details']['avgTimeMillis'] = target['details']['totalTimeMillis'] / target['details']['count']
+ target['stats']['totalTimeMillis'] += query_millis
+ target['stats']['count'] += 1
+ target['stats']['avgTimeMillis'] = target['stats']['totalTimeMillis'] / target['stats']['count']
View
4 dex/dex.py
@@ -123,6 +123,7 @@ def _process_query(self, input, parser):
self._run_stats['unparsableLineInfo']['unparsableLines'] += 1
self._run_stats['unparsableLineInfo']['unparsableLinesWithTime'] += 1
self._run_stats['unparsableLineInfo']['unparsedTimeMillis'] += int(parsed['stats']['millis'])
+ self._run_stats['unparsableLineInfo']['unparsedAvgTimeMillis'] = self._run_stats['unparsableLineInfo']['unparsedTimeMillis'] / self._run_stats['unparsableLineInfo']['unparsableLinesWithTime']
else:
self._run_stats['unparsableLineInfo']['unparsableLines'] += 1
self._run_stats['unparsableLineInfo']['unparsableLinesWithoutTime'] += 1
@@ -298,7 +299,8 @@ def _get_initial_run_stats(self):
('unparsableLineInfo', OrderedDict([('unparsableLines', 0),
('unparsableLinesWithoutTime', 0),
('unparsableLinesWithTime', 0),
- ('unparsedTimeMillis', 0)]))])
+ ('unparsedTimeMillis', 0),
+ ('unparsedAvgTimeMillis', 0)]))])
############################################################################
def _make_aggregated_report(self):
View
2  dex/test/test_dex.py
@@ -345,7 +345,7 @@ def test_report_aggregation(self):
TEST_COLLECTION)
test_dex._report.add_query_occurrence(result)
self.assertEqual(len(report), 1)
- self.assertEqual(report[0]['details']['count'], 1)
+ self.assertEqual(report[0]['stats']['count'], 1)
test_query = "{ $query: {}, $orderby: { simpleUnindexedField: null }}"
result = test_dex.generate_query_report(None,
View
8 docs/SCHEMA.md
@@ -31,7 +31,7 @@ A report on a query uniquely identified by queryMask.
"queryMask": <queryOccurrence.queryMask>,
"recommendation": <queryOccurrence.recommendation>,
"namespace": <queryReport.namespace>,
- "details": {
+ "stats": {
"count": <int>,
"totalTimeMillis": <int>,
"avgTimeMillis": <int>,
@@ -51,18 +51,20 @@ Primary internal data structure for Dex. Represents Dex"s assessment of a single
"recommendation": <recommendation>,
"indexAnalysis": <indexAnalysis>,
"namespace": <string>,
- "details": <details>,
+ "supported": <boolean>,
+ "parsed": <parsed>,
"queryAnalysis": <queryAnalysis>
}
```
-##queryOccurrence.details
+##queryOccurrence.parsed
Initial data structure extracted from a parsed log line or profile entry.
```
{
"queryMask": <string>,
"ns": <string>,
+ "supported": <boolean>,
"query": <json>,
"orderby": <json>,
"stats": {
Please sign in to comment.
Something went wrong with that request. Please try again.