Skip to content

chore(lint): migrate os.environ to env in MLObs integrations#17219

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits intomainfrom
brian.marks/migrate-mlobs
Apr 1, 2026
Merged

chore(lint): migrate os.environ to env in MLObs integrations#17219
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits intomainfrom
brian.marks/migrate-mlobs

Conversation

@bm1549
Copy link
Copy Markdown
Contributor

@bm1549 bm1549 commented Mar 31, 2026

Description

Part of a series migrating all os.environ/os.getenv usage in ddtrace/ to the centralized env MutableMapping from ddtrace.internal.settings (introduced in #17149).

This PR covers @DataDog/ml-observability owned files (3 files):

  • ddtrace/contrib/internal/mcp/patch.py
  • ddtrace/contrib/internal/ray/patch.py
  • ddtrace/contrib/internal/ray/utils.py

Stacks on: #17149

Sister PRs (same migration, different owners):

Testing

  • All ruff checks pass (ruff check --no-cache .)
  • All ast-grep tests pass (sg test)
  • No Python syntax errors in migrated files

Risks

None — mechanical replacement of os.environenv and os.getenv(k)env.get(k). No logic changes.

Additional Notes

The env object is a MutableMapping wrapping os.environ, so it is a drop-in replacement. See #17149 for design details.

Migrate `os.environ`/`os.getenv` to `ddtrace.internal.settings.env` in:
- ddtrace/contrib/internal/mcp/patch.py
- ddtrace/contrib/internal/ray/patch.py
- ddtrace/contrib/internal/ray/utils.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bm1549 bm1549 added changelog/no-changelog A changelog entry is not required for this PR. AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos labels Mar 31, 2026
bm1549 added a commit that referenced this pull request Mar 31, 2026
All `os.environ`/`os.getenv` usages in `ddtrace/` have been migrated to
`ddtrace.internal.settings.env` via the split migration PRs:
- apm-sdk-capabilities-python: #16724
- apm-core-python: #16725
- ci-app-libraries: #16726
- apm-idm-python (contrib): #16727
- asm-python: #17218
- ml-observability: #17219
- profiling-python: #17220
- data-streams-monitoring: #17221

This PR removes the "to be migrated" ignore lists, leaving only the
permanent exceptions:
- ddtrace/__init__.py — bootstrap: circular import with settings
- ddtrace/internal/native/__init__.py — bootstrap: imported before settings

Merge after all 8 migration PRs above are merged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gh-worker-dd-mergequeue-cf854d bot pushed a commit that referenced this pull request Mar 31, 2026
## Description

Part of a series migrating all `os.environ`/`os.getenv` usage in `ddtrace/` to the centralized `env` MutableMapping from `ddtrace.internal.settings` (introduced in #17149).

**This PR covers `@DataDog/profiling-python` owned files (3 files):**
- `ddtrace/internal/core/crashtracking.py`
- `ddtrace/internal/datadog/profiling/code_provenance.py`
- `ddtrace/internal/settings/profiling.py`

**Stacks on:** #17149

**Sister PRs (same migration, different owners):**
- `apm-sdk-capabilities-python`: #16724
- `apm-core-python`: #16725
- `ci-app-libraries`: #16726
- `apm-idm-python` (contrib): #16727
- `asm-python`: #17218
- `ml-observability`: #17219

## Testing

- All ruff checks pass (`ruff check --no-cache .`)
- All ast-grep tests pass (`sg test`)
- No Python syntax errors in migrated files

## Risks

None — mechanical replacement of `os.environ` → `env` and `os.getenv(k)` → `env.get(k)`. No logic changes.

## Additional Notes

The `env` object is a `MutableMapping` wrapping `os.environ`, so it is a drop-in replacement. See #17149 for design details.

Co-authored-by: brian.marks <brian.marks@datadoghq.com>
@bm1549 bm1549 marked this pull request as ready for review March 31, 2026 22:02
@bm1549 bm1549 requested a review from a team as a code owner March 31, 2026 22:02
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d bot merged commit b264ee2 into main Apr 1, 2026
387 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d bot deleted the brian.marks/migrate-mlobs branch April 1, 2026 02:51
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

Codeowners resolved as

ddtrace/contrib/internal/mcp/patch.py                                   @DataDog/ml-observability
ddtrace/contrib/internal/ray/patch.py                                   @DataDog/ml-observability
ddtrace/contrib/internal/ray/utils.py                                   @DataDog/ml-observability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants