Commit 25b2cd8
authored
Instrumentation Patch Removal and SPI AWS SDK Test Addition (#1120)
This is the final PR for the SPI aws-sdk instrumentation. It removes the
[opentelemetry-java-instrumentation](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch)
patch and adds comprehensive unit test coverage for AWS experimental
attributes in both AWS SDK v1.11 and v2.2 instrumentation packages. The
v2.2 package introduces 29 new experimental attributes while v1.11 adds
23 new experimental attributes. All attributes are now tested through
unit tests and/or contract tests.
### Description of changes:
#### AWS SDK v2.2 (awssdk_v2_2)
New attributes being tested:
1. AWS_BUCKET_NAME - testS3ExperimentalAttributes() & contract tests
2. AWS_QUEUE_URL - testSqsExperimentalAttributes() & contract tests
3. AWS_QUEUE_NAME - contract tests
4. AWS_STREAM_NAME - testKinesisExperimentalAttributes() & contract
tests
5. AWS_STREAM_ARN - testKinesisExperimentalAttributes() & contract tests
6. AWS_TABLE_NAME - testDynamoDbExperimentalAttributes()
7. AWS_GUARDRAIL_ID - contract tests
8. AWS_GUARDRAIL_ARN - contract tests
9. AWS_AGENT_ID - testBedrockAgentExperimentalAttributes() & contract
tests
10. AWS_DATA_SOURCE_ID - testBedrockDataSourceExperimentalAttributes() &
contract tests
11. AWS_KNOWLEDGE_BASE_ID -
testBedrockKnowledgeBaseExperimentalAttributes() & contract tests
12. GEN_AI_MODEL - testBedrockExperimentalAttributes() & contract tests
13. GEN_AI_SYSTEM - contract tests
14. GEN_AI_REQUEST_MAX_TOKENS - testBedrockExperimentalAttributes() &
contract tests
15. GEN_AI_REQUEST_TEMPERATURE - testBedrockExperimentalAttributes() &
contract tests
16. GEN_AI_REQUEST_TOP_P - contract tests
17. GEN_AI_RESPONSE_FINISH_REASONS - contract tests
18. GEN_AI_USAGE_INPUT_TOKENS - contract tests
19. GEN_AI_USAGE_OUTPUT_TOKENS - contract tests
20. AWS_STATE_MACHINE_ARN - testStepFunctionExperimentalAttributes() &
contract tests
21. AWS_STEP_FUNCTIONS_ACTIVITY_ARN -
testStepFunctionExperimentalAttributes() & contract tests
22. AWS_SNS_TOPIC_ARN - testSnsExperimentalAttributes() & contract tests
23. AWS_SECRET_ARN - testSecretsManagerExperimentalAttributes() &
contract tests
24. AWS_LAMBDA_NAME - testLambdaExperimentalAttributes()
25. AWS_LAMBDA_ARN - testLambdaArnExperimentalAttribute()
26. AWS_LAMBDA_RESOURCE_ID - testLambdaResourceIdExperimentalAttribute()
27. AWS_TABLE_ARN - testTableArnExperimentalAttribute()
28. AWS_AUTH_ACCESS_KEY - testAuthAccessKeyExperimentalAttribute()
29. AWS_AUTH_REGION - testAuthRegionExperimentalAttribute()
- Tests leverage AWS SDK v2's getValueForField() API for clean, mockable
attribute extraction
- Includes comprehensive testing for:
- Core AWS services (S3, DynamoDB, SQS, SNS, Kinesis, Lambda, Step
Functions, Secrets Manager)
- Bedrock Gen AI attributes with JSON parsing validation
- Bedrock resource attributes (Agent, Knowledge Base, Data Source)
- Authentication attributes (access key, region)
### AWS SDK v1.11 (awssdk_v1_11)
New attributes being tested:
1. AWS_STREAM_ARN - testKinesisExperimentalAttributes() & contract tests
2. AWS_TABLE_ARN - testTableArnExperimentalAttributes() (Service
identification only)
3. AWS_AGENT_ID - contract tests
4. AWS_KNOWLEDGE_BASE_ID - contract tests
5. AWS_DATA_SOURCE_ID - contract tests
6. AWS_GUARDRAIL_ID - testBedrockGuardrailAttributes() (Service
identification only) & contract tests
7. AWS_GUARDRAIL_ARN - testBedrockGuardrailAttributes() (Service
identification only) & contract tests
8. AWS_BEDROCK_RUNTIME_MODEL_ID - testBedrockRuntimeAttributes()
(Service identification only) & contract tests
9. AWS_BEDROCK_SYSTEM - contract tests
10. GEN_AI_REQUEST_MAX_TOKENS - contract tests
11. GEN_AI_REQUEST_TEMPERATURE - contract tests
12. GEN_AI_REQUEST_TOP_P - contract tests
13. GEN_AI_RESPONSE_FINISH_REASONS - contract tests
14. GEN_AI_USAGE_INPUT_TOKENS - contract tests
15. GEN_AI_USAGE_OUTPUT_TOKENS - contract tests
16. AWS_STATE_MACHINE_ARN - testStepFunctionsExperimentalAttributes() &
contract tests
17. AWS_STEP_FUNCTIONS_ACTIVITY_ARN - contract tests
18. AWS_SNS_TOPIC_ARN - testSnsExperimentalAttributes() & contract tests
19. AWS_SECRET_ARN - testSecretsManagerExperimentalAttributes() (Service
identification only) & contract tests
20. AWS_LAMBDA_NAME - testLambdaNameExperimentalAttributes()
21. AWS_LAMBDA_ARN - testLambdaArnExperimentalAttributes()
22. AWS_LAMBDA_RESOURCE_ID -
testLambdaResourceIdExperimentalAttributes() (Service identification
only)
23. AWS_AUTH_ACCESS_KEY - testAuthAccessKeyAttributes()
*V1.11 is harder to test:*
V1.11 uses Java reflection to dynamically find and call methods like
getFunctionName() on AWS request objects at runtime. This creates
several testing challenges:
- Mock Method Mismatch: When you mock an AWS request object, it doesn't
have the actual methods that reflection is trying to find. The
reflection silently fails and returns null, making tests pass even
though no attributes were extracted.
- Class Dependencies: To test properly, you'd need real AWS SDK classes
instead of mocks, creating tight coupling between tests and external
dependencies.
- Nested Object Complexity: Many attributes require traversing nested
properties, which means mocking entire object graphs with proper method
chains.
Contract tests sidestep these issues by using real AWS SDK objects
against LocalStack, testing the complete end-to-end flow including
actual reflection behavior without the complexity of mocking Java's
reflection system.
### Related
- PRs for aws-sdk v1.11: #1115 and #1117
- PRs for aws-sdk v2.2: #1111 and #1113
- Replaces patch: [current
patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch)
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.1 parent d471c70 commit 25b2cd8
File tree
12 files changed
+533
-4275
lines changed- .github
- actions/patch-dependencies
- patches
- scripts
- dependencyManagement
- instrumentation/aws-sdk
- src/test/java/software/amazon/opentelemetry/javaagent/instrumentation
- awssdk_v1_11
- awssdk_v2_2
- lambda-layer
- patches
- scripts
12 files changed
+533
-4275
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 52 | | |
56 | 53 | | |
57 | 54 | | |
| |||
60 | 57 | | |
61 | 58 | | |
62 | 59 | | |
63 | | - | |
64 | 60 | | |
65 | 61 | | |
66 | 62 | | |
| |||
101 | 97 | | |
102 | 98 | | |
103 | 99 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
Lines changed: 0 additions & 4193 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | | - | |
34 | 32 | | |
35 | 33 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 34 | | |
41 | | - | |
42 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
Lines changed: 220 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 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
0 commit comments