Commit 13957ffa by Colin Howe

Track getmore operations

parent a3ecfa94
# following PEP 386, versiontools will pick it up # following PEP 386, versiontools will pick it up
__version__ = (0, 1, 9, "final", 0) __version__ = (0, 1, 10, "final", 0)
...@@ -128,13 +128,10 @@ def _cursor_refresh(cursor_self): ...@@ -128,13 +128,10 @@ def _cursor_refresh(cursor_self):
def privar(name): def privar(name):
return getattr(cursor_self, '_Cursor__{0}'.format(name)) return getattr(cursor_self, '_Cursor__{0}'.format(name))
if privar('id') is not None:
# getMore not query - move on
return _original_methods['refresh'](cursor_self)
# NOTE: See pymongo/cursor.py+557 [_refresh()] and # NOTE: See pymongo/cursor.py+557 [_refresh()] and
# pymongo/message.py for where information is stored # pymongo/message.py for where information is stored
is_getmore = privar('id') is not None
# Time the actual query # Time the actual query
start_time = time.time() start_time = time.time()
result = _original_methods['refresh'](cursor_self) result = _original_methods['refresh'](cursor_self)
...@@ -149,6 +146,13 @@ def _cursor_refresh(cursor_self): ...@@ -149,6 +146,13 @@ def _cursor_refresh(cursor_self):
'stack_trace': _get_stacktrace(), 'stack_trace': _get_stacktrace(),
} }
if is_getmore:
# getMore not query - move on
query_data['cursor'] = id(cursor_self)
query_data['operation'] = 'getmore'
queries.append(query_data)
return result
# Collection in format <db_name>.<collection_name> # Collection in format <db_name>.<collection_name>
collection_name = privar('collection') collection_name = privar('collection')
query_data['collection'] = collection_name.full_name.split('.')[1] query_data['collection'] = collection_name.full_name.split('.')[1]
...@@ -178,6 +182,7 @@ def _cursor_refresh(cursor_self): ...@@ -178,6 +182,7 @@ def _cursor_refresh(cursor_self):
query_data['limit'] = abs(privar('limit') or 0) query_data['limit'] = abs(privar('limit') or 0)
query_data['query'] = query_son.get('$query') or query_son query_data['query'] = query_son.get('$query') or query_son
query_data['ordering'] = _get_ordering(query_son) query_data['ordering'] = _get_ordering(query_son)
query_data['cursor'] = id(cursor_self)
queries.append(query_data) queries.append(query_data)
......
...@@ -38,6 +38,7 @@ table.mongo-op-table tbody { ...@@ -38,6 +38,7 @@ table.mongo-op-table tbody {
<tr> <tr>
<th>Time (ms)</th> <th>Time (ms)</th>
<th>Operation</th> <th>Operation</th>
<th>Cursor</th>
<th>Collection</th> <th>Collection</th>
<th style="width: 100%">Query</th> <th style="width: 100%">Query</th>
<th>Ordering</th> <th>Ordering</th>
...@@ -51,6 +52,7 @@ table.mongo-op-table tbody { ...@@ -51,6 +52,7 @@ table.mongo-op-table tbody {
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}">
<td>{{ query.time|floatformat:"4" }}</td> <td>{{ query.time|floatformat:"4" }}</td>
<td>{{ query.operation|title }}</td> <td>{{ query.operation|title }}</td>
<td>{{ query.cursor }}</td>
<td>{{ query.collection }}</td> <td>{{ query.collection }}</td>
<td> <td>
{% if query.query %} {% if query.query %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment