Skip to content

Conversation

@genesor
Copy link
Member

@genesor genesor commented Nov 17, 2025

Description

This PR is the base PR for the incoming PR migrating all the os.environ (and equivalent) to a controlled and filtered env reader allowing only allow-listed configuration keys to be used in dd-trace-py for the larger initiative of Configuration Registry.

Testing

Risks

None

Additional Notes

This will be part of a PR stack.

@genesor genesor requested a review from mabdinur November 17, 2025 15:16
@github-actions
Copy link
Contributor

github-actions bot commented Nov 17, 2025

CODEOWNERS have been resolved as:

.sg/rules/os-environ-usage.yml                                          @DataDog/apm-core-python
.sg/tests/__snapshots__/os-environ-usage-snapshot.yml                   @DataDog/apm-core-python
.sg/tests/os-environ-usage-test.yml                                     @DataDog/apm-core-python

@genesor genesor changed the title feat(linter): Add new flake8 linter rule to disable access of os.environ feat(linter): add new flake8 linter rule to disable access of os.environ Nov 17, 2025
@github-actions
Copy link
Contributor

Bootstrap import analysis

Comparison of import times between this PR and base.

Summary

The average import time from this PR is: 216 ± 3 ms.

The average import time from base is: 222 ± 4 ms.

The import time difference between this PR and base is: -6.4 ± 0.2 ms.

Import time breakdown

The following import paths have shrunk:

ddtrace.auto 5.281 ms (2.45%)
ddtrace.bootstrap.sitecustomize 3.196 ms (1.48%)
ddtrace.bootstrap.preload 3.196 ms (1.48%)
ddtrace.internal.settings.dynamic_instrumentation 0.543 ms (0.25%)
ddtrace.internal.remoteconfig.client 0.525 ms (0.24%)
ddtrace.internal.remoteconfig.worker 0.524 ms (0.24%)
ddtrace 2.085 ms (0.97%)
ddtrace.trace 0.562 ms (0.26%)
ddtrace._logger 0.502 ms (0.23%)
ddtrace.internal.telemetry 0.502 ms (0.23%)
ddtrace.internal.telemetry.writer 0.502 ms (0.23%)
ddtrace.internal.utils.version 0.502 ms (0.23%)
ddtrace.internal._unpatched 0.037 ms (0.02%)
json 0.037 ms (0.02%)
json.decoder 0.037 ms (0.02%)
re 0.037 ms (0.02%)
enum 0.037 ms (0.02%)
types 0.037 ms (0.02%)

Copy link
Member

@brettlangdon brettlangdon left a comment

Choose a reason for hiding this comment

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

you might be able to use ast-grep for this as well

check .sg/ for some of our existing lint rules.

sg run --pattern 'os.environ'

can also do the same checks for importing environ/getenv from os, usage of getenv, etc etc

@genesor genesor changed the title feat(linter): add new flake8 linter rule to disable access of os.environ feat(linter): add new sg linter rule to disable access of os.environ Nov 20, 2025
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