Skip to content
Merged
Changes from all commits
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
10 changes: 10 additions & 0 deletions instana/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class Meter(object):
# We send Snapshot data every 10 minutes. This is the countdown variable.
snapshot_countdown = 0

# Collect the Snapshot only once and store the resulting Snapshot object here.
# We use this for every repeated snapshot send (every 10 minutes)
cached_snapshot = None

last_usage = None
last_collect = None
last_metrics = None
Expand Down Expand Up @@ -240,6 +244,9 @@ def handle_agent_tasks(self, task):
def collect_snapshot(self):
""" Collects snapshot related information to this process and environment """
try:
if self.cached_snapshot is not None:
return self.cached_snapshot

if "INSTANA_SERVICE_NAME" in os.environ:
appname = os.environ["INSTANA_SERVICE_NAME"]
elif "FLASK_APP" in os.environ:
Expand All @@ -260,6 +267,9 @@ def collect_snapshot(self):
djmw=self.djmw)
s.version = sys.version
s.versions = self.collect_modules()

# Cache the snapshot
self.cached_snapshot = s
except Exception as e:
logger.debug(e.message)
else:
Expand Down