Commit 572215e
authored
Base of AWS SDK v2.2 SPI Implementation (#1111)
Note: this is not the complete SPI implementation
### Issue
The current ADOT Java SDK implementation relies on a combination of
OpenTelemetry SPI and Git patches to extend the OTel SDK functionality.
This approach presents several challenges:
- Reduced modularity and maintainability
- Increased risk of errors during OTel SDK version upgrades
- Manual intervention required for patch management
- Limited ecosystem compatibility with upstream OpenTelemetry
- Difficulty in extending functionality for users
This is the skeleton set up for the SPI, which aims to remove the
[patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch)
for aws-sdk v2.2 by using OTel's InstrumentationModule SPI extension.
This instrumentation is essentially complementing the upstream java
agent. It is completely separate from upstream and instruments after the
Otel agent.
### Description of Changes
This PR sets up the foundational structure for AWS SDK v2.2
Instrumentation, moving away from the current patching approach. It
doesn't modify current ADOT functionality or the upstream span. It just
registers the ADOT SPI implementation and sets up the interceptor hooks.
#### Core Components
1. **AdotAwsSdkInstrumentationModule**
- Extends OpenTelemetry's `InstrumentationModule` SPI
- Registers custom interceptors in specific order:
1. Upstream AWS SDK execution interceptor
2. ADOT custom interceptor
- Ensures proper instrumentation sequencing through careful resource
registration
2. **AdotTracingExecutionInterceptor**
- Extends AWS SDK's `ExecutionInterceptor`
- Hooks into key SDK lifecycle points:
- `beforeTransmission`: Captures final SDK request after upstream
modifications
- `modifyResponse`: Processes response before span closure in upstream
- Will be used to enriches spans
- Acts as central coordinator for all the awssdk_v2_2 components
3. **Resources Folder**
- Registers the AdotAwsSdkInstrumentationModule into OTel's SPI
extension classpath in META-INF/services
- Registers AdotTracingExecutionInterceptor into AWS SDK's interceptor
classpath in software.amazon.awssdk.global.handlers
### Key Design Decisions
1. **Instrumentation Ordering**
- Deliberately structured to run after upstream OTel agent
- Ensures all upstream modifications are captured
- Maintains compatibility with existing instrumentation
2. **Lifecycle Hook Points**
- `beforeTransmission`: Last point to access modified request
- `modifyResponse`: Final opportunity to enrich span before closure
- Carefully chosen to ensure complete attribute capture
### Testing
- Verified existing functionality remains unchanged and contract tests
pass (all contract tests pass after following the steps
[here](https://github.com/aws-observability/aws-otel-java-instrumentation/tree/main/appsignals-tests))
- Confirmed build success with new structure
### Benefits of using SPI
- Improved Maintainability: Clear separation between OTel core and
AWS-specific instrumentation
- Better Extensibility: Users can more easily extend or modify
AWS-specific behavior
- Reduced Risk: Eliminates manual patching during OTel upgrades
- Enhanced Compatibility: Better alignment with OpenTelemetry's
extension mechanisms
- Clearer Code Organization: More intuitive structure for future
contributions
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.1 parent 2f48b77 commit 572215e
File tree
8 files changed
+195
-0
lines changed- instrumentation/aws-sdk
- src/main
- java/software/amazon/opentelemetry/javaagent/instrumentation/awssdk_v2_2
- resources
- META-INF/services
- software/amazon/awssdk/global/handlers
- otelagent
8 files changed
+195
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
0 commit comments