-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NH-68264 Upgrade c-lib 14 #259
Conversation
solarwinds_apm/apm_logging.py
Outdated
@classmethod | ||
def default_level(cls): | ||
"""Returns integer representation of default log type""" | ||
return cls.log_types["STDERR"] | ||
|
||
@classmethod | ||
def disabled_level(cls): | ||
"""Returns integer representation of disabled log type""" | ||
return cls.log_types["DISABLED"] | ||
|
||
@classmethod | ||
def is_valid_level(cls, level): | ||
"""Returns True if the provided level is a valid interger representation of log type, False otherwise.""" | ||
try: | ||
level = int(level) | ||
return bool(level in list(cls.log_types.values())) | ||
except (ValueError, TypeError): | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't these make more sense as default_type
/disabled_type
/is_valid_type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Changed in 62624db
solarwinds_apm/apm_logging.py
Outdated
# TODO no longer allow -1 | ||
# https://swicloud.atlassian.net/browse/NH-69517 | ||
debug_levels = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure the available levels and their meanings changed with oboe 14, not sure if you already updated these though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to keep level -1
as a valid level for customers to config log disabling, though it shouldn't be used internally. If level is -1
then log type will be disabled by ApmConfig.update_log_type
and log level should be ignored by oboe.
@@ -134,17 +135,29 @@ def __init__( | |||
self.__config["service_key"], | |||
self.service_name, | |||
) | |||
self.update_log_type() | |||
# update logging level of Python logging logger | |||
apm_logging.set_sw_log_level(self.__config["debug_level"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this up here instead of in _set_config_value
for clarity and so only called once.
log_types = { | ||
"STDERR": 0, | ||
"FILE": 2, | ||
"DISABLED": 4, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not included stdout nor null because there currently are no cases where APM Python would need to set them. But if too strict I can add them.
I've made some functionality changes starting at f126dc8 as per Slack thread and updated the PR description accordingly. Ready for a new review, please let me know if any questions/ideas 😺 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes !
Depends on #258
Upgrades APM Python to c-lib 14 which includes updated logging. APM Python therefore includes these updates:
Adds support for SW_APM_LOG_TYPE env var / logType json file configsEDIT This will not be a supported config.log_type
(with existingdebug_level
)log_type
anddebug_level
Deprecate SW_APM_DEBUG_LEVEL: -1. Remove later in https://swicloud.atlassian.net/browse/NH-69517. If customer sets -1 then _update_log_settings logs warning and automatically sets log_type to DISABLED and debug_level to 0 instead.EDIT We will be keeping the ability to setSW_APM_DEBUG_LEVEL: -1
.update_log_settings
helper sets internallog_type
to disabled if debug_level -1, or file if logname (filepath) is not none.Will be looking closer at log_type: in https://swicloud.atlassian.net/browse/NH-69396I might change the Python logging handler logic in a different PR.