Skip to content

Commit 81cc095

Browse files
committed
fix: Removing MonitoringClient
1 parent 45cb09c commit 81cc095

File tree

5 files changed

+254
-849
lines changed

5 files changed

+254
-849
lines changed

src/DIRAC/Core/Base/AgentModule.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,6 @@ def am_getCyclesDone(self):
284284
def am_Enabled(self):
285285
return self.am_getOption("Enabled")
286286

287-
def am_disableMonitoring(self):
288-
self.am_setOption("MonitoringEnabled", False)
289-
290-
def am_monitoringEnabled(self):
291-
return self.am_getOption("MonitoringEnabled")
292-
293287
def am_stopExecution(self):
294288
self.am_setModuleParam("alive", False)
295289

@@ -299,9 +293,7 @@ def __initializeMonitor(self):
299293
"""
300294
# This flag is used to activate ES based monitoring
301295
# if the "EnableActivityMonitoring" flag in "yes" or "true" in the cfg file.
302-
self.activityMonitoring = (
303-
Operations().getValue("EnableActivityMonitoring", False) and self.am_monitoringEnabled()
304-
)
296+
self.activityMonitoring = Operations().getValue("EnableActivityMonitoring", False)
305297
if self.activityMonitoring:
306298
# The import needs to be here because of the CS must be initialized before importing
307299
# this class (see https://github.com/DIRACGrid/DIRAC/issues/4793)

src/DIRAC/Core/Base/Script.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def initialize(cls, script=False, ignoreErrors=False, initializeMonitor=False, e
9696
:param bool initializeMonitor: to use monitoring
9797
:param bool enableCommandLine: enable parse command line
9898
"""
99-
# MonitoringClient has dependencies in DIRAC.Core.Base, so to avoid recurrence we'll leave it here
100-
from DIRAC.FrameworkSystem.Client.MonitoringClient import gMonitor
10199

102100
# Please do not call initialize in every file
103101
if cls.alreadyInitialized:
@@ -122,13 +120,6 @@ def initialize(cls, script=False, ignoreErrors=False, initializeMonitor=False, e
122120
sys.exit(1)
123121
if not userDisabled:
124122
cls.localCfg.enableCS()
125-
if initializeMonitor:
126-
gMonitor.setComponentType(gMonitor.COMPONENT_SCRIPT)
127-
gMonitor.setComponentName(cls.scriptName)
128-
gMonitor.setComponentLocation("script")
129-
gMonitor.initialize()
130-
else:
131-
gMonitor.disable()
132123
includeExtensionErrors()
133124
return True
134125

src/DIRAC/Core/Tornado/Server/private/BaseRequestHandler.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from DIRAC.Core.Utilities.JEncode import decode, encode
2727
from DIRAC.Core.Utilities.ReturnValues import isReturnStructure
2828
from DIRAC.Core.Security.X509Chain import X509Chain # pylint: disable=import-error
29-
from DIRAC.FrameworkSystem.Client.MonitoringClient import MonitoringClient
3029
from DIRAC.Resources.IdProvider.Utilities import getProvidersForInstance
3130
from DIRAC.Resources.IdProvider.IdProviderFactory import IdProviderFactory
3231

@@ -273,11 +272,6 @@ def _authzMYAUTH(self):
273272
# Lock to make sure that two threads are not initializing at the same time
274273
__init_lock = threading.RLock()
275274

276-
# MonitoringClient, we don't use gMonitor which is not thread-safe
277-
# We also need to add specific attributes for each service
278-
# See __initMonitoring method for the details.
279-
_monitor = None
280-
281275
# Definition of identity providers, used to authorize requests with access tokens
282276
_idps = IdProviderFactory()
283277
_idp = {}
@@ -291,17 +285,13 @@ def _authzMYAUTH(self):
291285
# Developer can overwrite this
292286
# if your handler is outside the DIRAC system package (src/DIRAC/XXXSystem/<path to your handler>)
293287
SYSTEM_NAME = None
294-
COMPONENT_NAME = None
295288

296289
# Base system URL. If defined, it is added as a prefix to the handler generated.
297290
BASE_URL = None
298291

299292
# Base handler URL
300293
DEFAULT_LOCATION = "/"
301294

302-
# Type of component, see MonitoringClient class
303-
MONITORING_COMPONENT = MonitoringClient.COMPONENT_WEB
304-
305295
# Prefix of the target methods names if need to use a special prefix. By default its "export_".
306296
METHOD_PREFIX = "export_"
307297

@@ -379,27 +369,6 @@ def __initMonitoring(cls, fullComponentName: str, fullUrl: str) -> dict:
379369
:param componentName: relative URL ``/<System>/<Component>``
380370
:param fullUrl: full URl like ``https://<host>:<port>/<System>/<Component>``
381371
"""
382-
383-
# Init extra bits of monitoring
384-
385-
cls._monitor = MonitoringClient()
386-
cls._monitor.setComponentType(cls.MONITORING_COMPONENT)
387-
388-
cls._monitor.initialize()
389-
390-
if tornado.process.task_id() is None: # Single process mode
391-
cls._monitor.setComponentName("Tornado/%s" % fullComponentName)
392-
else:
393-
cls._monitor.setComponentName("Tornado/CPU%d/%s" % (tornado.process.task_id(), fullComponentName))
394-
395-
cls._monitor.setComponentLocation(fullUrl)
396-
397-
cls._monitor.registerActivity("Queries", "Queries served", "Framework", "queries", MonitoringClient.OP_RATE)
398-
399-
cls._monitor.setComponentExtraParam("DIRACVersion", DIRAC.version)
400-
cls._monitor.setComponentExtraParam("platform", DIRAC.getPlatform())
401-
cls._monitor.setComponentExtraParam("startTime", datetime.utcnow())
402-
403372
cls._stats = {"requests": 0, "monitorLastStatsUpdate": time.time()}
404373

405374
return S_OK()
@@ -544,10 +513,7 @@ def _monitorRequest(self) -> None:
544513
"""Monitor action for each request.
545514
CAN be implemented by developer.
546515
"""
547-
self._monitor.setComponentLocation(self.request.path)
548516
self._stats["requests"] += 1
549-
self._monitor.setComponentExtraParam("queries", self._stats["requests"])
550-
self._monitor.addMark("Queries")
551517

552518
def _getMethod(self):
553519
"""Parse method name from incoming request.

0 commit comments

Comments
 (0)