Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions appstats_logger/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import threading
import time

from google.appengine.api import runtime


class Recorder(object):
"""In-memory state for the current request.
Expand Down Expand Up @@ -49,6 +51,8 @@ def __init__(self, env):

self.overhead = (time.time() - self.start_timestamp)

self.start_memory = runtime.memory_usage().current()

def record_rpc_request(self, service, call, request, response, rpc):
"""Record the request of an RPC call.

Expand Down Expand Up @@ -135,6 +139,8 @@ def get_profile_data(self):
return {
'overhead': int(self.overhead * 1000),
'exec_time': int((time.time() - self.start_timestamp) * 1000),
'memory_start': self.start_memory,
'memory_end': runtime.memory_usage().current(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost wonder if we should just emit the end and delta? You can always compute start from that, and probably you'll want either ending memory or the delta, I presume?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I'll switch to that.

'calls': self.traces
}