File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ class Meter(object):
114114 # We send Snapshot data every 10 minutes. This is the countdown variable.
115115 snapshot_countdown = 0
116116
117+ # Collect the Snapshot only once and store the resulting Snapshot object here.
118+ # We use this for every repeated snapshot send (every 10 minutes)
119+ cached_snapshot = None
120+
117121 last_usage = None
118122 last_collect = None
119123 last_metrics = None
@@ -240,6 +244,9 @@ def handle_agent_tasks(self, task):
240244 def collect_snapshot (self ):
241245 """ Collects snapshot related information to this process and environment """
242246 try :
247+ if self .cached_snapshot is not None :
248+ return self .cached_snapshot
249+
243250 if "INSTANA_SERVICE_NAME" in os .environ :
244251 appname = os .environ ["INSTANA_SERVICE_NAME" ]
245252 elif "FLASK_APP" in os .environ :
@@ -260,6 +267,9 @@ def collect_snapshot(self):
260267 djmw = self .djmw )
261268 s .version = sys .version
262269 s .versions = self .collect_modules ()
270+
271+ # Cache the snapshot
272+ self .cached_snapshot = s
263273 except Exception as e :
264274 logger .debug (e .message )
265275 else :
You can’t perform that action at this time.
0 commit comments