Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit ac04fbb

Browse files
dragoluigiemrekultursay
authored andcommitted
Modified python agent to include the request log id into the breakpoint labels for GAE Classic applications only.
This is a re-submit of cl/125829312 that was rolled back. It should work now that we checked in the modified serializer to/from json/protobuf[2|3]. I will send another CL for the updated aeta python test, i prefer having the test get in into a separate CL (so that @emrekultursay can run the plain test the day after we check in against nightly and also the updated one). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130292452
1 parent 9492633 commit ac04fbb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/googleclouddebugger/capture_collector.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import sys
2525
import types
2626

27+
import labels
2728
import cdbg_native as native
2829

2930
# Externally defined functions to actually log a message. If these variables
@@ -32,6 +33,9 @@
3233
log_warning_message = None
3334
log_error_message = None
3435

36+
# Externally defined function to collect the request log id.
37+
request_log_id_collector = None
38+
3539
_PRIMITIVE_TYPES = (int, long, float, complex, str, unicode, bool,
3640
types.NoneType)
3741
_DATE_TYPES = (datetime.date, datetime.time, datetime.timedelta)
@@ -164,6 +168,8 @@ def Collect(self, top_frame):
164168
# didn't make it point to var_index of 0 ("buffer full")
165169
self.TrimVariableTable(i)
166170

171+
self._CaptureRequestLogId()
172+
167173
def CaptureFrameLocals(self, frame):
168174
"""Captures local variables and arguments of the specified frame.
169175
@@ -381,6 +387,22 @@ def ProcessBufferFull(variables):
381387
ProcessBufferFull(self._var_table)
382388
ProcessBufferFull(self.breakpoint['evaluatedExpressions'])
383389

390+
def _CaptureRequestLogId(self):
391+
"""Captures the request log id if possible.
392+
393+
The request log id is stored inside the breakpoint labels.
394+
"""
395+
# pylint: disable=not-callable
396+
if callable(request_log_id_collector):
397+
request_log_id = request_log_id_collector()
398+
if request_log_id:
399+
# We have a request_log_id, save it into the breakpoint labels
400+
if 'labels' not in self.breakpoint:
401+
self.breakpoint['labels'] = {}
402+
403+
self.breakpoint['labels'][
404+
labels.Breakpoint.REQUEST_LOG_ID] = request_log_id
405+
384406
@staticmethod
385407
def _NormalizePath(path):
386408
"""Converts an absolute path to a relative one.

0 commit comments

Comments
 (0)