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-65068 Add is_lambda checks and todos to APM Python #211

Merged
merged 14 commits into from
Nov 7, 2023

Conversation

tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Oct 31, 2023

This adds is_lambda in-code checks and distro setup to APM Python. Also adds TODOs for what's next for lambda mode that I hope are self-explanatory. Big pieces to note:

(1) _get_extension_components

The base of this approach is a little draconian: new function ApmConfig._get_extension_components declares which parts of the c-lib extension should be no-op depending on agent_enabled and is_lambda. Right now it's:

agent_enabled T, is_lambda F -> init all c-lib including Reporter
agent_enabled T, is_lambda T -> all no-op
agent_enabled F              -> all no-op

After introducing c-lib settings API usage update in https://swicloud.atlassian.net/browse/NH-64716, it will be

agent_enabled T, is_lambda F -> init all c-lib including Reporter EXCEPT OboeAPI
agent_enabled T, is_lambda T -> init ONLY c-lib OboeAPI
agent_enabled F              -> all no-op

I'm doing it this way because we do not want any non-OboeAPI business triggered by APM Python when in lambda, based on testing with Jerry.

(2) _calculate_agent_enabled_config_lambda

New function ApmConfig._calculate_agent_enabled_config_lambda is separate from the config check if outside lambda. I'm thinking the only user-side config that would disable APM Python inside lambda would be if SW_APM_AGENT_ENABLED is false. As per testing c-lib updates with Jerry, no need for service key.

(3) calculate_liboboe_decision

Updates existing function calculate_liboboe_decision with a condition if is_lambda. It drops trace at the moment until c-lib settings API usage update in https://swicloud.atlassian.net/browse/NH-64716


Please let me know what you think!

try:
# SolarWindsDistro._configure does setdefault so this shouldn't
# be None, but safer and more explicit this way
environ_exporters = os.environ.get(
OTEL_TRACES_EXPORTER,
INTL_SWO_DEFAULT_TRACES_EXPORTER,
).split(",")
# If not using the default propagators,
# If not using the default exporters,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just fixing an old typo

@@ -530,7 +572,6 @@ def _snake_to_camel_case(key):
self.agent_enabled = cnf_agent_enabled

available_cnf = set(self.__config.keys())
# TODO after alpha: is_lambda
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per Slack chat starting here, we won't configure token_* in APM Python like we did in AO. So no longer needed.

@@ -611,11 +652,12 @@ def update_with_env_var(self) -> None:
self.agent_enabled = env_agent_enabled

available_envvs = set(self.__config.keys())
# TODO after alpha: is_lambda
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -700,7 +742,6 @@ def _set_config_value(self, keys_str: str, val: Any) -> Any:
)
self.__config[key] = oboe_trigger_trace
elif keys == ["reporter"]:
# TODO: support 'lambda'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -46,7 +47,6 @@
)
from solarwinds_apm.apm_fwkv_manager import SolarWindsFrameworkKvManager
from solarwinds_apm.apm_meter_manager import SolarWindsMeterManager
from solarwinds_apm.apm_noop import Reporter
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was actually the wrong import used for type checking before. Removed this and added solarwinds_apm.extension.oboe.Reporter below.

@@ -165,12 +170,16 @@ def _configure_sampler(
),
)

def _configure_metrics_span_processor(
def _configure_inbound_metrics_span_processor(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renaming for clarity

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review October 31, 2023 23:06
@tammy-baylis-swi tammy-baylis-swi requested a review from a team October 31, 2023 23:06
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.

Looks good !

@tammy-baylis-swi
Copy link
Contributor Author

Thanks @raphael-theriault-swi ! Could I please have another check? I had to resolve a changelog merge conflict.

@tammy-baylis-swi tammy-baylis-swi merged commit 9ec9afb into main Nov 7, 2023
11 checks passed
@tammy-baylis-swi tammy-baylis-swi deleted the NH-65068-is-lambda branch November 7, 2023 18:41
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