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

PR-2 Plugin configuration from airflow.cfg #32

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

pschrimpf
Copy link

Multiple dimensions
Local docker setup

Multiple dimensions
Local docker setup
@pschrimpf pschrimpf requested a review from a team November 7, 2022 13:40
@pschrimpf
Copy link
Author

@newrelic/python I would suggest removing the test on python27
This version is outdated since 2020.
And the last airflow version supporting python27 is 1.10, which is EOL since June 17, 2021.
Would you agree?

@TimPansino
Copy link
Contributor

Python 2.7 is unfortunately something we're going to be stuck supporting for quite some time. A lot of high profile customers for Python still use 2.7, so we're not willing to drop support yet. It looks like the error is a dependency issue, probably should be addressed separately.

What's the purpose of the nr_dim metrics? If they're static from a config file is there any real point in sending them?

@pschrimpf
Copy link
Author

Hi @TimPansino, sorry for the late reply. I have been on vacation.
I see, I try to get the dependencies working again for 2.7.

The "static dimensions"-feature is a request from the field. They would like to be able to send more information for a given airflow instance, which helps identify, separate, or aggregate the data of multiple airflow instances. As this is now possible via airflow.cfg they could take care of it via a Configuration Management tool for example.

@pschrimpf
Copy link
Author

@newrelic/python I fixed the dependency issue for python2.7 - how are we going to proceed? Any other remarks on that PR?

Copy link
Contributor

@TimPansino TimPansino left a comment

Choose a reason for hiding this comment

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

This PR needs a bit more work, I may step in and do some of the edits to ensure we have stable code with no potential crashes for customers.

This doesn't include any additional tests to test the changes made here, it could use a test for dimensional metrics at the very least if not also config file vs environment testing.

@@ -24,5 +24,5 @@
version = "{version!s}"
""",
},
install_requires=("apache-airflow>=1.8", "newrelic-telemetry-sdk>=0.4.0,<0.5"),
install_requires=("email-validator==1.2.1", "apache-airflow>=1.8", "newrelic-telemetry-sdk>=0.4.0,<0.5"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
install_requires=("email-validator==1.2.1", "apache-airflow>=1.8", "newrelic-telemetry-sdk>=0.4.0,<0.5"),
install_requires=("apache-airflow>=1.8", "newrelic-telemetry-sdk>=0.4.0,<0.5"),

This seems like a mistake. Why are we adding another dependency?

Copy link
Author

Choose a reason for hiding this comment

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

HI @TimPansino, the email validator is a sub-dependency coming with apache-airflow. Unfortunately, not pinned to a version compatible with Python2.7. I thought it would be better to pin that particular dependency instead of apache-airflow.

src/newrelic_airflow_plugin/newrelic_plugin.py Outdated Show resolved Hide resolved
src/newrelic_airflow_plugin/newrelic_plugin.py Outdated Show resolved Hide resolved
Comment on lines 56 to 69
# Set default configs
if PROP_INSERT_KEY not in nr_config and ENV_INSERT_KEY in os.environ:
nr_config[PROP_INSERT_KEY] = os.environ.get(ENV_INSERT_KEY)

if PROP_SERVICE_NAME not in nr_config:
nr_config[PROP_SERVICE_NAME] = os.environ.get(ENV_SERVICE_NAME, "Airflow")

if PROP_HOST not in nr_config:
nr_config[PROP_HOST] = os.environ.get(ENV_HOST, None)

if PROP_HARVESTER_INTERVAL not in nr_config:
nr_config[PROP_HARVESTER_INTERVAL] = 5

return nr_config
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably shouldn't mutate the user's config, and instead do this the other way around. Retrieve our config section with a function and check for environment variables if the key isn't present. If neither is present use a default.

Copy link
Author

Choose a reason for hiding this comment

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

I am not really sure what you mean. For me it looks like your described approach is how it is already implemented. 😅

Comment on lines -124 to +180
if "NEW_RELIC_INSERT_KEY" in os.environ and not cls.patched:
if PROP_INSERT_KEY in config and not cls.patched:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not equivalent if we swap config strategies. Will need to check both conditions.

Copy link
Author

Choose a reason for hiding this comment

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

At this moment the config should already have the value from the environment variable (if not directly defined in airflow.cfg)

src/newrelic_airflow_plugin/newrelic_plugin.py Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
@pschrimpf pschrimpf force-pushed the feature/airflow_cfg branch 9 times, most recently from bcd21e9 to b558b61 Compare November 22, 2022 14:30
@CLAassistant
Copy link

CLAassistant commented Nov 29, 2023

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants