Skip to content

Commit b2cd24f

Browse files
committed
Documentation
1 parent 25585cb commit b2cd24f

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/main/java/datadog/trace/instrumentation/aws/v0/AwsSdkModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.List;
88
import java.util.Map;
99

10+
/** Groups the instrumentations for AWS SDK 1.11.0+. */
1011
@AutoService(InstrumenterModule.class)
1112
public final class AwsSdkModule extends InstrumenterModule.Tracing {
1213

docs/how_instrumentations_work.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ At this point the instrumentation should override the method `muzzleDirective()`
101101

102102
## Instrumentation classes
103103

104-
The Instrumentation class is where the Instrumentation begins. It will:
104+
The Instrumentation class is where the instrumentation begins. It will:
105105

106106
1. Use Matchers to choose target types (i.e., classes)
107107
2. From only those target types, use Matchers to select the members (i.e., methods) to instrument.
@@ -110,8 +110,9 @@ The Instrumentation class is where the Instrumentation begins. It will:
110110
Instrumentation classes:
111111

112112
1. Must be annotated with `@AutoService(InstrumenterModule.class)`
113-
2. Should extend one of the six abstract TargetSystem `InstrumenterModule` classes
114-
3. Should implement one of the `Instrumenter` interfaces
113+
2. Should be declared in a file that ends with `Instrumentation.java`
114+
3. Should extend one of the six abstract TargetSystem `InstrumenterModule` classes
115+
4. Should implement one of the `Instrumenter` interfaces
115116

116117
For example:
117118

@@ -136,6 +137,31 @@ public class RabbitChannelInstrumentation extends InstrumenterModule.Tracing
136137
| `InstrumenterModule.`[`Usm`](https://github.com/DataDog/dd-trace-java/blob/82a3400cd210f4051b92fe1a86cd1b64a17e005e/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/InstrumenterModule.java#L273) | |
137138
| [`InstrumenterModule`](https://github.com/DataDog/dd-trace-java/blob/82a3400cd210f4051b92fe1a86cd1b64a17e005e/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/InstrumenterModule.java) | Avoid extending `InstrumenterModule` directly. When no other TargetGroup is applicable we generally default to `InstrumenterModule.Tracing` |
138139

140+
### Grouping Instrumentations
141+
142+
Related instrumentations may be grouped under a single `InstrumenterModule` to share common details
143+
such as integration name, helpers, context store use, and optional `classLoaderMatcher()`.
144+
145+
Module classes:
146+
147+
1. Must be annotated with `@AutoService(InstrumenterModule.class)`
148+
2. Should be declared in a file that ends with `Module.java`
149+
3. Should extend one of the six abstract TargetSystem `InstrumenterModule` classes
150+
4. Should have a `typeInstrumentations()` method that returns the instrumentations in the group
151+
5. Should NOT implement one of the `Instrumenter` interfaces
152+
153+
> [!WARNING]
154+
> Grouped instrumentations must NOT be annotated with `@AutoService(InstrumenterModule.class)
155+
> and must NOT extend any of the six abstract TargetSystem `InstrumenterModule` classes
156+
157+
Existing instrumentations can be grouped under a new module, assuming they share the same integration name.
158+
159+
For each member instrumentation:
160+
1. Remove `@AutoService(InstrumenterModule.class)`
161+
2. Remove `extends InstrumenterModule...`
162+
3. Move the list of helpers to the module, merging as necessary
163+
4. Move the context store map to the module, merging as necessary
164+
139165
### Type Matching
140166

141167
Instrumentation classes should implement an

0 commit comments

Comments
 (0)