feat(config): enable telemetry when SCA is on independently from appsec by florentinl · Pull Request #672 · DataDog/datadog-lambda-python

Choose a reason for hiding this comment

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

The reason this code was added here was we must ensure the DD_INSTRUMENTATION_TELEMETRY_ENABLED is set before any ddtrace code is imported.

I agree. As explained in the PR notes, this is the reason why we need the config to be resolved before the from datadog_lambda.patch import patch_all line of __init__.py.

Can we ensure that we the change you're proposing? How can we enforce it?

We can eagerly import the config in __init__.py and add a test to ensure that importing config.py does not import ddtrace. Would that work for you or does it feel like an unnecessary constraint ? Let me suggest something.

The idea was to reuse the parsing of environment variables done in config if possible. This also looked like some configuration and it felt natural to put it in "config.py".
I can keep it in __init__.py if it make more sense.