Skip to content

Commit f825a54

Browse files
authored
[info] unknown ver if failed module load, custom if custom check. (#3488)
* [info] `unknown` ver if failed module load, `custom` if custom check. [info] custom is more appropriate. [info] allow manual override of check version. * [info] pick the nit :)
1 parent e6b389d commit f825a54

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

checks/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,14 @@ def __init__(self, name, init_config, agentConfig, instances=None):
379379
def set_manifest_path(self, manifest_path):
380380
self.manifest_path = manifest_path
381381

382-
def set_check_version(self, manifest=None):
383-
version = AGENT_VERSION
382+
def set_check_version(self, version=None, manifest=None):
383+
_version = version or AGENT_VERSION
384384

385385
if manifest is not None:
386-
version = "{core}:{sdk}".format(core=AGENT_VERSION,
386+
_version = "{core}:{sdk}".format(core=AGENT_VERSION,
387387
sdk=manifest.get('version', 'unknown'))
388388

389-
self.check_version = version
389+
self.check_version = _version
390390

391391
def get_instance_proxy(self, instance, uri):
392392
proxies = self.proxies.copy()

checks/collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def run(self, checksd=None, start_event=True, configs_reloaded=False):
475475
if not self.continue_running:
476476
return
477477
check_status = CheckStatus(check_name, None, None, None, None,
478-
check_version=info.get('version'),
478+
check_version=info.get('version', 'unknown'),
479479
init_failed_error=info['error'],
480480
init_failed_traceback=info['traceback'])
481481
check_statuses.append(check_status)

config.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,8 @@ def get_valid_check_class(check_name, check_path):
973973
return True, check_class, {}
974974

975975

976-
def _initialize_check(check_config, check_name, check_class, agentConfig, manifest_path):
976+
def _initialize_check(check_config, check_name, check_class, agentConfig,
977+
manifest_path, version_override=None):
977978
init_config = check_config.get('init_config') or {}
978979
instances = check_config['instances']
979980
try:
@@ -989,14 +990,20 @@ def _initialize_check(check_config, check_name, check_class, agentConfig, manife
989990

990991
if manifest_path:
991992
check.set_manifest_path(manifest_path)
992-
check.set_check_version(load_manifest(manifest_path))
993+
994+
if not version_override:
995+
check.set_check_version(manifest=load_manifest(manifest_path))
996+
else:
997+
check.set_check_version(version=version_override)
993998
except Exception as e:
994999
log.exception('Unable to initialize check %s' % check_name)
9951000
traceback_message = traceback.format_exc()
9961001
manifest = load_manifest(manifest_path)
9971002
if manifest is not None:
9981003
check_version = '{core}:{vers}'.format(core=AGENT_VERSION,
9991004
vers=manifest.get('version', 'unknown'))
1005+
elif version_override:
1006+
check_version = version_override
10001007
else:
10011008
check_version = AGENT_VERSION
10021009

@@ -1066,8 +1073,13 @@ def load_check_from_places(check_config, check_name, checks_places, agentConfig)
10661073
log.warn("The SDK check (%s) was designed for a different agent core "
10671074
"or couldnt be validated - behavior is undefined" % check_name)
10681075

1076+
version_override = None
1077+
if not manifest_path and agentConfig['additional_checksd'] in check_path:
1078+
version_override = 'custom' # custom check
1079+
1080+
10691081
load_success, load_failure = _initialize_check(
1070-
check_config, check_name, check_class, agentConfig, manifest_path
1082+
check_config, check_name, check_class, agentConfig, manifest_path, version_override
10711083
)
10721084

10731085
_update_python_path(check_config)

0 commit comments

Comments
 (0)