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
12 changes: 12 additions & 0 deletions .claude/skills/add-apm-integrations/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ pattern before writing new code. Use it as a template.
- `testImplementation` dependencies for tests
- `muzzle { pass { } }` directives (see Step 9)
4. Register the new module in `settings.gradle.kts` in **alphabetical order**
5. Register the integration name in `metadata/supported-configurations.json`, or
`checkInstrumenterModuleConfigurations` fails. The name in `super(...)` maps to env var
`DD_TRACE_<NAME>_ENABLED` (`.` and `-` become `_`, uppercased — `couchbase-3` →
`DD_TRACE_COUCHBASE_3_ENABLED`). Add a `"type": "boolean"` entry, in alphabetical order, with
aliases `DD_TRACE_INTEGRATION_<NAME>_ENABLED` and `DD_INTEGRATION_<NAME>_ENABLED`. Set `default`
to the module's real default — `"true"`, or `"false"` if it overrides `defaultEnabled()` (e.g.
OpenTelemetry, Hazelcast). Declaring several names (`super("a", "b")`) means one entry each.

## Step 5 – Write the InstrumenterModule

Expand Down Expand Up @@ -193,11 +200,15 @@ Run these commands in order and fix any failures before proceeding:
./gradlew :dd-java-agent:instrumentation:$framework-$version:muzzle
./gradlew :dd-java-agent:instrumentation:$framework-$version:test
./gradlew :dd-java-agent:instrumentation:$framework-$version:latestDepTest
./gradlew checkInstrumenterModuleConfigurations
./gradlew spotlessCheck
```

**If muzzle fails:** check for missing helper class names in `helperClassNames()`.

**If `checkInstrumenterModuleConfigurations` fails:** an integration name from `super(...)` is missing
(or mismatched) in `metadata/supported-configurations.json` — see Step 4, item 5.

**If tests fail:** verify span lifecycle order (start → activate → error → finish → close), helper registration,
and `contextStore()` map entries match actual usage.

Expand All @@ -208,6 +219,7 @@ and `contextStore()` map entries match actual usage.
Output this checklist and confirm each item is satisfied:

- [ ] `settings.gradle.kts` entry added in alphabetical order
- [ ] `metadata/supported-configurations.json` has a `DD_TRACE_<NAME>_ENABLED` entry (+ the two aliases) for every name passed to `super(...)`
- [ ] `build.gradle` has `compileOnly` deps and `muzzle` directives with `assertInverse = true`
- [ ] `@AutoService(InstrumenterModule.class)` annotation present on the module class
- [ ] `helperClassNames()` lists ALL referenced helpers (including inner, anonymous, and enum synthetic classes)
Expand Down
11 changes: 11 additions & 0 deletions docs/add_new_instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ public class GoogleHttpClientInstrumentation extends InstrumenterModule.Tracing
}
```

> [!IMPORTANT]
> **The instrumentation name controls a config flag that must be registered.** The name passed to
> `super(...)` becomes the config key `dd.trace.<name>.enabled` → environment variable
> `DD_TRACE_<NAME>_ENABLED` (`.` and `-` become `_`, then uppercased — e.g. `couchbase-3` →
> `DD_TRACE_COUCHBASE_3_ENABLED`). Every such name must be registered in
> `metadata/supported-configurations.json` with the two standard aliases
> (`DD_TRACE_INTEGRATION_<NAME>_ENABLED` and `DD_INTEGRATION_<NAME>_ENABLED`), or the
> `checkInstrumenterModuleConfigurations` Gradle task fails the build. A module declaring multiple
> names (`super("a", "b")`) needs **one entry per name**. See
> [Add new configurations](./add_new_configurations.md) for the JSON entry shape.

## Match the target class

In this case we target only one known class to instrument. This is the class which contains the method this
Expand Down