Skip to content
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

Merged
merged 18 commits into from
Jan 4, 2024
Merged

NH-68264 Upgrade c-lib 14 #259

merged 18 commits into from
Jan 4, 2024

Conversation

tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Dec 19, 2023

Depends on #258

Upgrades APM Python to c-lib 14 which includes updated logging. APM Python therefore includes these updates:

  1. Adds support for SW_APM_LOG_TYPE env var / logType json file configs EDIT This will not be a supported config.
  2. Init Reporter with log_type (with existing debug_level)
  3. Init OboeAPI with log_type and debug_level
  4. 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 set SW_APM_DEBUG_LEVEL: -1.
  5. update_log_settings helper sets internal log_type to disabled if debug_level -1, or file if logname (filepath) is not none.
  6. Removed those icky conditional imports of OboeAPI
  7. Slight change from NH-68264 Configurator does the only OboeAPI init #258 to init OboeAPI in ApmConfig instead of in Configurator

Will be looking closer at log_type: in https://swicloud.atlassian.net/browse/NH-69396

I might change the Python logging handler logic in a different PR.

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review December 22, 2023 22:16
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner December 22, 2023 22:16
Comment on lines 52 to 69
@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

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Changed in 62624db

Comment on lines 79 to 81
# TODO no longer allow -1
# https://swicloud.atlassian.net/browse/NH-69517
debug_levels = {

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

Copy link
Contributor Author

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.

Base automatically changed from NH-68264-single-oboeapi-init to main January 2, 2024 16:15
@@ -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"])
Copy link
Contributor Author

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.

Comment on lines +44 to +48
log_types = {
"STDERR": 0,
"FILE": 2,
"DISABLED": 4,
}
Copy link
Contributor Author

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.

@tammy-baylis-swi
Copy link
Contributor Author

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 😺

Copy link
Member

@raphael-theriault-swi raphael-theriault-swi left a 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 !

@tammy-baylis-swi tammy-baylis-swi merged commit 08c5368 into main Jan 4, 2024
11 checks passed
@tammy-baylis-swi tammy-baylis-swi deleted the NH-68264-upgrade-clib-14 branch January 4, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants