Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/dd-trace-scope-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@codemod/dd-trace-js-v6-add-link-object-argument': minor
'@codemod/dd-trace-js-v6-migration-recipe': minor
'@codemod/dd-trace-js-v6-flatten-ingestion-options': minor
'@codemod/dd-trace-js-v6-move-experimental-appsec-options': minor
'@codemod/dd-trace-js-v6-move-experimental-iast-options': minor
'@codemod/dd-trace-js-v6-rename-b3-style': minor
'@codemod/dd-trace-js-v6-rename-plugin-list-options': minor
'@codemod/dd-trace-js-v6-rename-profiling-env-vars': minor
'@codemod/dd-trace-js-v6-rename-runtime-id-env-var': minor
---

Publish all dd-trace-js 5→6 codemods under the **`@codemod`** scope using **`@codemod/dd-trace-js-v6-<slug>`** (SDK + **destination** major **v6** + codemod slug). Update docs, workflow sources, and workspace `pnpm` filters to match. Fix recipe metadata test to satisfy lint. Use **`dd-trace-js`** (not `dd-trace`) in `codemod.yaml` registry keywords for discoverability. Add **`apm`**, **`nodejs`**, and **`v6`** to each package's `codemod.yaml` `keywords` list.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
if: steps.changed.outputs.files != ''
run: pnpm run lint ${{ steps.changed.outputs.files }}

- name: Markdown link check
run: pnpm run docs:links

- name: Test (changed codemods)
if: steps.codemods.outputs.dirs != ''
run: |
Expand Down Expand Up @@ -100,6 +103,7 @@ jobs:
cache: pnpm

- run: pnpm install --frozen-lockfile
- run: pnpm run docs:links
- run: pnpm run ci

changeset-check:
Expand Down
5 changes: 0 additions & 5 deletions .lintstagedrc.json

This file was deleted.

14 changes: 14 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @param {string[]} files */
function excludePnpmLockfile(files) {
return files.filter((f) => !f.endsWith('pnpm-lock.yaml'))
}

export default {
'*.{ts,js,mts,mjs}': ['oxfmt --write', 'oxlint --type-aware --type-check --fix'],
/** @param {string[]} files */
'*.{json,yaml,yml}': (files) => {
const filtered = excludePnpmLockfile(files)
return filtered.length ? [`oxfmt --write ${filtered.join(' ')}`] : []
},
'codemods/**/scripts/*.ts': 'bash scripts/test-staged.sh',
}
6 changes: 6 additions & 0 deletions .markdown-link-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"retryOn429": true,
"retryCount": 3,
"fallbackRetryDelay": "2s",
"aliveStatusCodes": [200, 206, 403]
}
16 changes: 10 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ pnpm run lint
# Lint and auto-fix
pnpm run lint:fix

# Run all codemod package tests (dd-trace-* workspace packages)
# Run all codemod package tests (`@codemod/dd-trace-js-v6-*` workspace packages)
pnpm run test

# Typecheck all codemod packages
pnpm run check-types

# Same checks as the push job on main (tests + typecheck)
pnpm run ci

# Verify URLs in tracked Markdown (also runs in CI)
pnpm run docs:links
```

Run one workspace package (the `pnpm --filter` value is the `name` field in that package’s `package.json`):
Expand All @@ -51,8 +54,8 @@ The hook only inspects **staged** files. Files you did not touch can still fail

## CI

- **Pull requests to `main`:** `.github/workflows/ci.yml` installs with `pnpm install --frozen-lockfile`, runs **oxfmt** / **oxlint** on changed files, runs **test** and **check-types** only for codemod packages touched by the diff, and enforces **changesets** (see below).
- **Pushes to `main`:** the same workflow runs full-workspace `pnpm run ci` (all `dd-trace-*` tests and typechecks).
- **Pull requests to `main`:** `.github/workflows/ci.yml` installs with `pnpm install --frozen-lockfile`, runs **oxfmt** / **oxlint** on changed files, **`pnpm run docs:links`** on tracked Markdown, runs **test** and **check-types** only for codemod packages touched by the diff, and enforces **changesets** (see below).
- **Pushes to `main`:** the same workflow runs **`pnpm run docs:links`** and full-workspace `pnpm run ci` (all `@codemod/dd-trace-js-v6-*` tests and typechecks).

Match that locally before you push.

Expand Down Expand Up @@ -85,9 +88,9 @@ Commit the new markdown file under `.changeset/` with your PR.
## Release workflow

1. Merge a PR that includes one or more changesets into `main`.
2. [`.github/workflows/release.yml`](./.github/workflows/release.yml) consumes changesets, commits **Version Packages** to `main`, syncs `codemod.yaml` versions, creates **`name@vversion`** git tags for newly versioned packages, and publishes those packages with [`codemod/publish-action`](https://github.com/codemod-com/publish-action).
2. [`.github/workflows/release.yml`](./.github/workflows/release.yml) consumes changesets, commits **Version Packages** to `main`, syncs `codemod.yaml` versions, creates **`name@vversion`** git tags for newly versioned packages, and publishes those packages with [`codemod/publish-action`](https://github.com/codemod/publish-action).

Do not hand-edit the `version` field in package `package.json` or `codemod.yaml` to “simulate” a release — automation owns bumps. The **Publish Codemod (Manual)** workflow ([`.github/workflows/publish.yml`](./.github/workflows/publish.yml)) is for emergencies: supply the path **under** `codemods/`, e.g. `apm/nodejs/dd-trace-js/v6/add-link-object-argument`.
Do not hand-edit the `version` field in package `package.json` or `codemod.yaml` to “simulate” a release — automation owns bumps. The **Publish Codemod (Manual)** workflow ([`.github/workflows/publish.yml`](./.github/workflows/publish.yml)) is for emergencies: supply the path **under** `codemods/`, e.g. `apm/nodejs/dd-trace-js/v6/add-link-object-argument` or `apm/nodejs/dd-trace-js/v6/dd-trace-js-v6-migration-recipe`.

## Adding a new codemod

Expand All @@ -106,7 +109,8 @@ codemods/<product>/<stack>/<library>/<migration>/<slug>/

Conventions:

- Prefer the existing naming pattern for dd-trace-js 5→6 packages: `dd-trace-5-to-6-<slug>` in `package.json` / `codemod.yaml`.
- Prefer the registry naming pattern **`@codemod/<sdk>-<destination-major>-<codemod-slug>`** (example: `@codemod/dd-trace-js-v6-flatten-ingestion-options` for migrating **to** dd-trace-js **v6**) in `package.json` / `codemod.yaml`.
- The filesystem folder name under `codemods/.../<migration>/` should usually match that slug, but it may differ when a shorter registry name is clearer—see `rename-b3-single-header-propagation-style/` publishing as `@codemod/dd-trace-js-v6-rename-b3-style` in [dd-trace-js v6 README](./codemods/apm/nodejs/dd-trace-js/v6/README.md).
- Keep rewrites conservative. If a step needs a human decision, Datadog account work, or Remote Configuration, prefer a detector, recipe parameter, or issue draft instead of an unsafe transform.

Use an existing sibling codemod in the same migration folder as a template.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ destination-major folder—for example [dd-trace-js 5.x → 6.x](./codemods/apm/
Quick start for the orchestrated dd-trace-js 5→6 workflow:

```bash
npx codemod dd-trace-5-to-6-migration-recipe --target <path>
npx codemod @codemod/dd-trace-js-v6-migration-recipe --target <path>
```

Packages are listed in the [Codemod Registry](https://app.codemod.com/registry).
Expand Down
90 changes: 43 additions & 47 deletions codemods/apm/nodejs/dd-trace-js/v6/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
# dd-trace-js 5.x → 6.x

JSSG codemods aligned with the upstream [dd-trace-js migration guide](https://github.com/DataDog/dd-trace-js/blob/master/MIGRATING.md). Each directory under this folder is one Codemod package (metadata, workflow, scripts, tests).
JSSG codemods aligned with the upstream [dd-trace-js migration guide](https://github.com/DataDog/dd-trace-js/blob/master/MIGRATING.md#50-to-60-unreleased). Each directory under this folder is one Codemod package (metadata, workflow, scripts, tests). Published names follow **`@codemod/dd-trace-js-v6-<slug>`** (the `v6` segment is the **destination** dd-trace-js major—the same **6.x** line as this repository folder).

Run codemods with the [Codemod CLI](https://docs.codemod.com/cli):
Use the [Codemod CLI](https://docs.codemod.com/cli) as in the repository [Usage](../../../../../README.md#usage) section (`npx codemod <codemod-name> --target <path>`).

```bash
npx codemod <codemod-name> --target <path>
```

Packages are published to the [Codemod Registry](https://app.codemod.com/registry?q=dd-trace-5-to-6).
Packages are published to the [Codemod Registry](https://app.codemod.com/registry?q=dd-trace-js-v6).

## Codemods

#### `dd-trace-5-to-6-migration-recipe`
#### `@codemod/dd-trace-js-v6-migration-recipe`

Runs the implemented dd-trace 5.0 to 6.0 codemods in sequence, then can run a final report-only AI review for unresolved migration blockers.

```bash
npx codemod dd-trace-5-to-6-migration-recipe --target <path>
npx codemod @codemod/dd-trace-js-v6-migration-recipe --target <path>
```

Optional recipe parameters:
Expand All @@ -30,86 +26,86 @@ Optional recipe parameters:
review.

See
[dd-trace-5-to-6-migration-recipe](https://app.codemod.com/registry/dd-trace-5-to-6-migration-recipe). · [source](./dd-trace-5-to-6-migration-recipe/)
[@codemod/dd-trace-js-v6-migration-recipe](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-migration-recipe). · [source](./dd-trace-js-v6-migration-recipe/)

#### `dd-trace-5-to-6-add-link-object-argument`
#### `@codemod/dd-trace-js-v6-add-link-object-argument`

Rewrites `Span.addLink(context, attributes)` to
`Span.addLink({ context, attributes })`.

```bash
npx codemod dd-trace-5-to-6-add-link-object-argument --target <path>
npx codemod @codemod/dd-trace-js-v6-add-link-object-argument --target <path>
```

See
[dd-trace-5-to-6-add-link-object-argument](https://app.codemod.com/registry/dd-trace-5-to-6-add-link-object-argument). · [source](./add-link-object-argument/)
[@codemod/dd-trace-js-v6-add-link-object-argument](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-add-link-object-argument). · [source](./add-link-object-argument/)

#### `dd-trace-5-to-6-rename-plugin-list-options`
#### `@codemod/dd-trace-js-v6-rename-plugin-list-options`

Renames `whitelist` / `blacklist` to `allowlist` / `blocklist` for Datadog
`http`, `ioredis`, `iovalkey`, and `redis` plugin configs.

```bash
npx codemod dd-trace-5-to-6-rename-plugin-list-options --target <path>
npx codemod @codemod/dd-trace-js-v6-rename-plugin-list-options --target <path>
```

See
[dd-trace-5-to-6-rename-plugin-list-options](https://app.codemod.com/registry/dd-trace-5-to-6-rename-plugin-list-options). · [source](./rename-plugin-list-options/)
[@codemod/dd-trace-js-v6-rename-plugin-list-options](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-rename-plugin-list-options). · [source](./rename-plugin-list-options/)

#### `dd-trace-5-to-6-move-experimental-iast-options`
#### `@codemod/dd-trace-js-v6-move-experimental-iast-options`

Moves safe `experimental.iast.*` programmatic options to top-level `iast.*`.
Skips `securityControlsConfiguration`, which is env-only in v6.

```bash
npx codemod dd-trace-5-to-6-move-experimental-iast-options --target <path>
npx codemod @codemod/dd-trace-js-v6-move-experimental-iast-options --target <path>
```

See
[dd-trace-5-to-6-move-experimental-iast-options](https://app.codemod.com/registry/dd-trace-5-to-6-move-experimental-iast-options). · [source](./move-experimental-iast-options/)
[@codemod/dd-trace-js-v6-move-experimental-iast-options](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-move-experimental-iast-options). · [source](./move-experimental-iast-options/)

Optional report-only AI review for skipped security controls:

```bash
npx codemod dd-trace-5-to-6-move-experimental-iast-options \
npx codemod @codemod/dd-trace-js-v6-move-experimental-iast-options \
--target <path> \
--param run_ai_review=true
```

#### `dd-trace-5-to-6-move-experimental-appsec-options`
#### `@codemod/dd-trace-js-v6-move-experimental-appsec-options`

Moves safe `experimental.appsec.*` programmatic options to top-level `appsec.*`
and rewrites `experimental.appsec.standalone.enabled` to `apmTracingEnabled`.
Skips options that must move to Datadog UI / Remote Configuration.

```bash
npx codemod dd-trace-5-to-6-move-experimental-appsec-options --target <path>
npx codemod @codemod/dd-trace-js-v6-move-experimental-appsec-options --target <path>
```

See
[dd-trace-5-to-6-move-experimental-appsec-options](https://app.codemod.com/registry/dd-trace-5-to-6-move-experimental-appsec-options). · [source](./move-experimental-appsec-options/)
[@codemod/dd-trace-js-v6-move-experimental-appsec-options](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-move-experimental-appsec-options). · [source](./move-experimental-appsec-options/)

Optional report-only AI review for skipped AppSec Remote Configuration options:

```bash
npx codemod dd-trace-5-to-6-move-experimental-appsec-options \
npx codemod @codemod/dd-trace-js-v6-move-experimental-appsec-options \
--target <path> \
--param run_ai_review=true
```

#### `dd-trace-5-to-6-flatten-ingestion-options`
#### `@codemod/dd-trace-js-v6-flatten-ingestion-options`

Flattens `ingestion.sampleRate` and `ingestion.rateLimit` to top-level
`sampleRate` and `rateLimit`.

```bash
npx codemod dd-trace-5-to-6-flatten-ingestion-options --target <path>
npx codemod @codemod/dd-trace-js-v6-flatten-ingestion-options --target <path>
```

See
[dd-trace-5-to-6-flatten-ingestion-options](https://app.codemod.com/registry/dd-trace-5-to-6-flatten-ingestion-options). · [source](./flatten-ingestion-options/)
[@codemod/dd-trace-js-v6-flatten-ingestion-options](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-flatten-ingestion-options). · [source](./flatten-ingestion-options/)

#### `dd-trace-5-to-6-rename-profiling-env-vars`
#### `@codemod/dd-trace-js-v6-rename-profiling-env-vars`

Renames profiling env var aliases removed in v6 inside JS/TS source:

Expand All @@ -119,59 +115,59 @@ Renames profiling env var aliases removed in v6 inside JS/TS source:
- `DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED`

```bash
npx codemod dd-trace-5-to-6-rename-profiling-env-vars --target <path>
npx codemod @codemod/dd-trace-js-v6-rename-profiling-env-vars --target <path>
```

See
[dd-trace-5-to-6-rename-profiling-env-vars](https://app.codemod.com/registry/dd-trace-5-to-6-rename-profiling-env-vars). · [source](./rename-profiling-env-vars/)
[@codemod/dd-trace-js-v6-rename-profiling-env-vars](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-rename-profiling-env-vars). · [source](./rename-profiling-env-vars/)

Optional AI config-file step for exact active occurrences in `.env`,
Dockerfile, YAML, shell, CI, and deployment files:

```bash
npx codemod dd-trace-5-to-6-rename-profiling-env-vars \
npx codemod @codemod/dd-trace-js-v6-rename-profiling-env-vars \
--target <path> \
--param run_ai_config_step=true
```

#### `dd-trace-5-to-6-rename-runtime-id-env-var`
#### `@codemod/dd-trace-js-v6-rename-runtime-id-env-var`

Renames `DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED` to
`DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED` inside JS/TS source.

```bash
npx codemod dd-trace-5-to-6-rename-runtime-id-env-var --target <path>
npx codemod @codemod/dd-trace-js-v6-rename-runtime-id-env-var --target <path>
```

See
[dd-trace-5-to-6-rename-runtime-id-env-var](https://app.codemod.com/registry/dd-trace-5-to-6-rename-runtime-id-env-var). · [source](./rename-runtime-id-env-var/)
[@codemod/dd-trace-js-v6-rename-runtime-id-env-var](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-rename-runtime-id-env-var). · [source](./rename-runtime-id-env-var/)

Optional AI config-file step for exact active occurrences in `.env`,
Dockerfile, YAML, shell, CI, and deployment files:

```bash
npx codemod dd-trace-5-to-6-rename-runtime-id-env-var \
npx codemod @codemod/dd-trace-js-v6-rename-runtime-id-env-var \
--target <path> \
--param run_ai_config_step=true
```

#### `dd-trace-5-to-6-rename-b3-style`
#### `@codemod/dd-trace-js-v6-rename-b3-style`

Renames exact propagation style values from `"b3 single header"` to `"b3"` in
JS/TS Datadog configuration source.

```bash
npx codemod dd-trace-5-to-6-rename-b3-style --target <path>
npx codemod @codemod/dd-trace-js-v6-rename-b3-style --target <path>
```

See
[dd-trace-5-to-6-rename-b3-style](https://app.codemod.com/registry/dd-trace-5-to-6-rename-b3-style). · [source](./rename-b3-single-header-propagation-style/)
[@codemod/dd-trace-js-v6-rename-b3-style](https://app.codemod.com/registry/@codemod/dd-trace-js-v6-rename-b3-style). · [source](./rename-b3-single-header-propagation-style/)

Optional AI config-file step for exact active `DD_TRACE_PROPAGATION_STYLE`
occurrences in `.env`, Dockerfile, YAML, shell, CI, and deployment files:

```bash
npx codemod dd-trace-5-to-6-rename-b3-style \
npx codemod @codemod/dd-trace-js-v6-rename-b3-style \
--target <path> \
--param run_ai_config_step=true
```
Expand All @@ -180,16 +176,16 @@ npx codemod dd-trace-5-to-6-rename-b3-style \

| Migration guide item | Automation |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `Span.addLink(spanContext, attributes)` removed | `dd-trace-5-to-6-add-link-object-argument` |
| Plugin `whitelist` / `blacklist` options removed from types | `dd-trace-5-to-6-rename-plugin-list-options` |
| `experimental.iast` configuration removed | `dd-trace-5-to-6-move-experimental-iast-options` |
| `Span.addLink(spanContext, attributes)` removed | `@codemod/dd-trace-js-v6-add-link-object-argument` |
| Plugin `whitelist` / `blacklist` options removed from types | `@codemod/dd-trace-js-v6-rename-plugin-list-options` |
| `experimental.iast` configuration removed | `@codemod/dd-trace-js-v6-move-experimental-iast-options` |
| `iast.securityControlsConfiguration` is env-only | Report-only AI review; manual move to `DD_IAST_SECURITY_CONTROLS_CONFIGURATION` |
| AppSec extended-data-collection programmatic config removed | Report-only AI review; manual Datadog UI / Remote Configuration move |
| `experimental.appsec` configuration removed | `dd-trace-5-to-6-move-experimental-appsec-options` |
| `ingestion` option removed | `dd-trace-5-to-6-flatten-ingestion-options` |
| Profiling experimental env aliases removed | `dd-trace-5-to-6-rename-profiling-env-vars` |
| `DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED` removed | `dd-trace-5-to-6-rename-runtime-id-env-var` |
| `"b3 single header"` renamed to `"b3"` | `dd-trace-5-to-6-rename-b3-style` |
| `experimental.appsec` configuration removed | `@codemod/dd-trace-js-v6-move-experimental-appsec-options` |
| `ingestion` option removed | `@codemod/dd-trace-js-v6-flatten-ingestion-options` |
| Profiling experimental env aliases removed | `@codemod/dd-trace-js-v6-rename-profiling-env-vars` |
| `DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED` removed | `@codemod/dd-trace-js-v6-rename-runtime-id-env-var` |
| `"b3 single header"` renamed to `"b3"` | `@codemod/dd-trace-js-v6-rename-b3-style` |
| `experimental.b3` removed | Issue drafted; deterministic rewrite deferred |
| `DD_TRACE_STARTUP_LOGS` defaults to `true` | Manual operational decision |

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dd-trace-5-to-6-add-link-object-argument
# @codemod/dd-trace-js-v6-add-link-object-argument

## 0.2.0

Expand Down
Loading
Loading