Skip to content

Commit 46a0f8b

Browse files
authored
Don't init profile / meter damon threads when not active. (#295)
* only init profile / meter when active Don't init profile / meter damon threads when not active, since thread is expensive in python. * only profiling when active Don't run profiling when config.agent_profile_active set to False.
1 parent 1803a71 commit 46a0f8b

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

skywalking/agent/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ def start(self) -> None:
259259
import grpc.experimental.gevent as grpc_gevent
260260
grpc_gevent.init_gevent()
261261

262-
profile.init()
263-
meter.init(force=True) # force re-init after fork()
262+
if config.agent_profile_active:
263+
profile.init()
264+
if config.agent_meter_reporter_active:
265+
meter.init(force=True) # force re-init after fork()
264266

265267
self.__bootstrap() # calls init_threading
266268

skywalking/trace/context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def new_entry_span(self, op: str, carrier: Optional[Carrier] = None, inherit: Op
149149

150150
parent = self.peek()
151151
# start profiling if profile_context is set
152-
if self.profile_status is None:
152+
if config.agent_profile_active and self.profile_status is None:
153153
self.profile_status = profile.profile_task_execution_service.add_profiling(self,
154154
self.segment.segment_id,
155155
op)
@@ -192,6 +192,8 @@ def new_exit_span(self, op: str, peer: str,
192192
return span
193193

194194
def profiling_recheck(self, span: Span, op_name: str):
195+
if not config.agent_profile_active:
196+
return
195197
# only check first span, e.g, first opname is correct.
196198
if span.sid != 0:
197199
return

0 commit comments

Comments
 (0)