-
Notifications
You must be signed in to change notification settings - Fork 46
feat(config): enable telemetry when SCA is on independently from appsec #672
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
feat(config): enable telemetry when SCA is on independently from appsec #672
Conversation
1716faf to
e6c42de
Compare
Currently we are turning telemetry off (except for asm case) for both performance concerns and incpompatibilies (many errors). Therefore I believe we need to keep it. btw, what's Runtime SCA? |
| # Telemetry is required for Appsec Software Composition Analysis | ||
| os.environ["DD_INSTRUMENTATION_TELEMETRY_ENABLED"] = os.environ.get( | ||
| "DD_APPSEC_ENABLED", "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.
The reason this code was added here was we must ensure the DD_INSTRUMENTATION_TELEMETRY_ENABLED is set before any ddtrace code is imported. Can we ensure that we the change you're proposing? How can we enforce it?
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.
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.
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 think any of those options are fine. As long as we can ensure it's being set before importing ddtrace. I like your idea of adding a test to check for this.
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 need to ensure that the DD_INSTRUMENTATION_TELEMETRY_ENABLED is set before any ddtrace code is imported.
Okay wasn't aware of the arguments for keeping it disabled, thank you for the insight. I am definitely not challenging this decision.
Runtime Software Composition Analysis (SCA) is a Code Security product that analyzes third party dependencies installed on the application. It relies on instrumentation telemetry to collect the list of dependencies and their versions. |
8bf9772 to
3d7e4fc
Compare
3d7e4fc to
f451e8a
Compare
What does this PR do?
My understanding is that we want instrumentation telemetry to be off by default in python lambda. There is currently a bypass for AppSec that is a bit weird using env vars directly in
__init__.py. I added another bypass for Runtime SCA and moved the logic to theconfigmodule to rely on parsed env vars instead.Motivation
A customer asked if he could enable Runtime SCA without enabling AAP (AppSec) in Lambda. This currently requires setting
DD_INSTRUMENTATION_TELEMETRY_ENABLEDmanually, we could make it a bit more easy.Testing Guidelines
Additional Notes
In
ddtrace, the telemetry_writer is instantiated and enabled on first import ifDD_INSTRUMENTATION_TELEMETRY_ENABLEDis not explicitely set to false => The current telemetry enablement code indatadog_lambda/tracing.pyis therefore redundant and unnecessary so I removed it.The
config.enable_telemetryflag was therefore not necessary anymore and I removed it.This small refactor relies on the fact that the configuration is resolved before importing ddtrace which happens transitively through
cold_start.py. Should we make this more explicit by importing it in__init__.pyor is this already clear enough ?Types of Changes
Check all that apply