Skip to content

Commit 9a76dda

Browse files
anahatAWSthpierce
andauthored
AWS SDK v2.2 SPI Patch Migration (#1113)
Note: This is a continuation of #1111 #### Description of Changes This implementation builds on the foundation established in PR #1111, transforming the structural setup into a fully functional SPI-based solution that will replace our current patching approach. This PR does not change the current ADOT functionality because patches have not been removed. The next/final PR for v2.2 will remove the patches for aws-sdk-2.2 and have unit tests to ensure correct SPI functionality and behaviour. The final PR will also pass all the contract-tests once patches are removed. #### Changes include: - Migration of patched files into proper package structure: NOTE: We are not copying entire files from upstream. Instead, we only migrated the new components that were added by our patches and the methods that use these AWS-specific components. I deliberately removed any code that was untouched by our patches to avoid duplicating upstream instrumentation code. This selective migration ensures we maintain only our AWS-specific additions while letting OTel handle its base functionality. - `AwsExperimentalAttributes` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L2587) creates new class - `AwsSdkRequest` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L2673) on [this otel file](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequest.java) - `AwsSdkRequestType` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L2751) on [this otel file](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequestType.java) - `BedrockJsonParser` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L2860) creates new class - `FieldMapper` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L3145) on [this otel file](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapper.java) - `Serializer` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L3164) on [this otel file](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Serializer.java) - `BedrockJsonParserTest` - [patch](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/.github/patches/opentelemetry-java-instrumentation.patch#L3474) creates new class - Setup of dependent files directly copied from upstream aws-sdk: - `MethodHandleFactory` - copy-pasted from [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/MethodHandleFactory.java) - `FieldMapping` - copy-pasted from [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapping.java) - `AwsJsonProtocolFactoryAccess` - copy-pasted from [here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsJsonProtocolFactoryAccess.java) These added files: - Access and modify span attributes - Provide consistent formatting tools for span attributes - Can be updated at our convenience if needed The classes we copied from upstream are just helper utilities that make it easier to inject span attributes during instrumentation. They're not core functionality that needs to stay in sync with upstream changes, rather standalone utilities that support our simpler, independent instrumentation without creating version lock-in. They're independent of OTel's core functionality, so we don't face the same version dependency issues we had with patching. We're just following upstream's structure for consistency. #### OTel attribution for copied files The 3 coped files have the OTel header included in them. This follows section 4 a)-c) in the ADOT [LICENSE](https://github.com/aws-observability/aws-otel-java-instrumentation/blob/main/LICENSE#L89) #### Testing - Existing functionality verified - Contract tests passing - Build successful #### Related - Skeleton PR for aws-sdk v2.2: #1111 - 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. --------- Co-authored-by: Thomas Pierce <thp@amazon.com>
1 parent fd17846 commit 9a76dda

File tree

15 files changed

+1589
-11
lines changed

15 files changed

+1589
-11
lines changed

instrumentation/aws-sdk/README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,36 @@ The AdotAwsSdkTracingExecutionInterceptor hooks onto OpenTelemetry's spans durin
7979
1. `beforeTransmission`: the latest point where the SDK request can be obtained after it is modified by the upstream's interceptor
8080
2. `modifyResponse`: the latest point to access the SDK response before the span closes in the upstream afterExecution method
8181

82-
_**Important Note:**_
83-
The upstream interceptor closes the span in `afterExecution`. That hook is inaccessible for span modification.
84-
`modifyResponse` is our final hook point, giving us access to both the fully processed response and active span.
82+
All the span lifecycle hooks provided by AWS SDK ExecutionInterceptor can be found [here.](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/interceptor/ExecutionInterceptor.html)
8583

84+
_**Important Notes:**_
85+
- The upstream interceptor's last point of request modification occurs in [beforeTransmission](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java#L237).
86+
- The upstream interceptor closes the span in [afterExecution](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java#L348). That hook is inaccessible for span modification.
87+
`modifyResponse` is our final hook point, giving us access to both the fully processed response and active span.
8688

89+
**High-Level Sequence Diagram:**
90+
91+
![img.png](sequence-diagram-2.2.png)
92+
93+
_Class Functionalities:_
94+
- `AdotAwsSdkTracingExecutionInterceptor`
95+
- Intercepts AWS SDK calls to create and enrich OpenTelemetry spans with AWS attributes
96+
- Coordinates the attribute mapping process
97+
- `FieldMapper`
98+
- Maps the AWS SDK fields to span attributes
99+
- Coordinates with Serializer for value conversion
100+
- `FieldMapping`
101+
- Defines what fields to map from SDK to spans
102+
- Groups mappings by type (REQUEST/RESPONSE)
103+
- `MethodHandleFacotry`
104+
- Provides fast, cached access to AWS SDK object fields for better performance
105+
- Used by FieldMapper for efficient field value extraction
106+
- `Serializer`
107+
- Converts AWS SDK objects and Bedrock objects into string values that can be used as span attributes
108+
- Works with BedrockJsonParser for LLM responses
109+
- `AwsJsonProtocolFactoryAccess`
110+
- Enables access to AWS SDK's internal JSON serialization capabilities for complex SDK objects
111+
- Uses reflection to access internal SDK classes
112+
- Caches method handles for performance
113+
- `BedrockJasonParser`
114+
- Parses and extracts specific attributes from Bedrock LLM responses for GenAI telemetry

instrumentation/aws-sdk/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@
1616
plugins {
1717
java
1818
id("com.gradleup.shadow")
19+
id("groovy")
1920
}
2021

2122
base.archivesBaseName = "aws-instrumentation-aws-sdk"
2223

2324
dependencies {
2425
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
26+
compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
2527
compileOnly("com.amazonaws:aws-java-sdk-core:1.11.0")
2628
compileOnly("software.amazon.awssdk:aws-core:2.2.0")
29+
compileOnly("software.amazon.awssdk:aws-json-protocol:2.2.0")
30+
2731
compileOnly("net.bytebuddy:byte-buddy")
32+
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
33+
34+
testImplementation("com.google.guava:guava")
35+
testImplementation("io.opentelemetry.javaagent:opentelemetry-testing-common")
2836

2937
testImplementation("com.amazonaws:aws-java-sdk-core:1.11.0")
3038
testImplementation("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
Loading

instrumentation/aws-sdk/src/main/java/software/amazon/opentelemetry/javaagent/instrumentation/awssdk_v2_2/AdotAwsSdkInstrumentationModule.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,28 @@ public AdotAwsSdkInstrumentationModule() {
3737
@Override
3838
public int order() {
3939
// Ensure this runs after OTel (> 0)
40-
return 99;
40+
return Integer.MAX_VALUE;
4141
}
4242

4343
@Override
4444
public List<String> getAdditionalHelperClassNames() {
4545
return Arrays.asList(
46-
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AdotAwsSdkTracingExecutionInterceptor");
46+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AdotAwsSdkTracingExecutionInterceptor",
47+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsSdkRequest",
48+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsSdkRequestType",
49+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.FieldMapper",
50+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.FieldMapping",
51+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.FieldMapping$Type",
52+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsExperimentalAttributes",
53+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.BedrockJsonParser",
54+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.BedrockJsonParser$JsonPathResolver",
55+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.BedrockJsonParser$LlmJson",
56+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.BedrockJsonParser$JsonParser",
57+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.MethodHandleFactory",
58+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.MethodHandleFactory$1",
59+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.Serializer",
60+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsJsonProtocolFactoryAccess",
61+
"software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsSdkRequestType$AttributeKeys");
4762
}
4863

4964
/**

instrumentation/aws-sdk/src/main/java/software/amazon/opentelemetry/javaagent/instrumentation/awssdk_v2_2/AdotAwsSdkTracingExecutionInterceptor.java

Lines changed: 120 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,138 @@
1515

1616
package software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2;
1717

18+
import static io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil.getBoolean;
19+
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsExperimentalAttributes.AWS_AUTH_ACCESS_KEY;
20+
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsExperimentalAttributes.AWS_AUTH_REGION;
21+
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsExperimentalAttributes.GEN_AI_SYSTEM;
22+
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2.AwsSdkRequestType.BEDROCKRUNTIME;
23+
24+
import io.opentelemetry.api.trace.Span;
25+
import software.amazon.awssdk.auth.credentials.AwsCredentials;
26+
import software.amazon.awssdk.auth.signer.AwsSignerExecutionAttribute;
27+
import software.amazon.awssdk.core.SdkRequest;
1828
import software.amazon.awssdk.core.SdkResponse;
1929
import software.amazon.awssdk.core.interceptor.*;
30+
import software.amazon.awssdk.regions.Region;
2031

32+
/**
33+
* This interceptor manages the AWS SDK requests and responses for attribute mapping. Here's the
34+
* flow:
35+
*
36+
* <p>1. Request Phase (beforeTransmission):
37+
*
38+
* <ul>
39+
* <li>Receives the SDK request before it's sent to AWS
40+
* <li>Creates an AwsSdkRequest object containing request metadata
41+
* <li>Stores this AwsSdkRequest in ExecutionAttributes using ADOT_AWS_SDK_REQUEST_ATTRIBUTE
42+
* <li>Maps request attributes to the current span
43+
* </ul>
44+
*
45+
* <p>2. Response Phase (modifyResponse):
46+
*
47+
* <ul>
48+
* <li>Retrieves the stored AwsSdkRequest from ExecutionAttributes via
49+
* ADOT_AWS_SDK_REQUEST_ATTRIBUTE
50+
* <li>Uses this request context to properly map response fields to the span
51+
* <li>Cleans up by removing the stored request from ExecutionAttributes
52+
* </ul>
53+
*
54+
* <p>The ExecutionAttributes object persists throughout the entire request lifecycle, allowing
55+
* correlation between the request and response phases. All ExecutionInterceptor's have access to
56+
* the ExecutionAttributes.
57+
*
58+
* @see <a
59+
* href="https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/interceptor/ExecutionInterceptor.html">reference</a>
60+
*/
2161
public class AdotAwsSdkTracingExecutionInterceptor implements ExecutionInterceptor {
2262

23-
// This is the latest point we can obtain the Sdk Request after it is modified by the upstream
24-
// TracingInterceptor. It ensures upstream handles the request and applies its changes first.
63+
private static final String GEN_AI_SYSTEM_BEDROCK = "aws.bedrock";
64+
private static final ExecutionAttribute<AwsSdkRequest> ADOT_AWS_SDK_REQUEST_ATTRIBUTE =
65+
new ExecutionAttribute<>(
66+
AdotAwsSdkTracingExecutionInterceptor.class.getName() + ".AwsSdkRequest");
67+
68+
private final FieldMapper fieldMapper = new FieldMapper();
69+
private final boolean captureExperimentalSpanAttributes =
70+
getBoolean("otel.instrumentation.aws-sdk.experimental-span-attributes", true);
71+
72+
/**
73+
* This method coordinates the request attribute mapping process. This is the latest point we can
74+
* obtain the Sdk Request after it is modified by the upstream TracingInterceptor. It ensures
75+
* upstream handles the request and applies its changes to the span first. We use this hook to
76+
* extract the ADOT AWS attributes from the Sdk Request and map them to the span via the
77+
* FieldMapper.
78+
*
79+
* <p>Upstream's last Sdk Request modification: @see <a
80+
* href="https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java#L237">reference</a>
81+
*/
2582
@Override
2683
public void beforeTransmission(
27-
Context.BeforeTransmission context, ExecutionAttributes executionAttributes) {}
84+
Context.BeforeTransmission context, ExecutionAttributes executionAttributes) {
2885

29-
// This is the latest point we can obtain the Sdk Response before span completion in upstream's
30-
// afterExecution. This ensures we capture attributes from the final, fully modified response
31-
// after all upstream interceptors have processed it.
86+
if (captureExperimentalSpanAttributes) {
87+
SdkRequest request = context.request();
88+
Span currentSpan = Span.current();
89+
90+
try {
91+
if (request == null || currentSpan == null || !currentSpan.getSpanContext().isValid()) {
92+
return;
93+
}
94+
95+
AwsCredentials credentials =
96+
executionAttributes.getAttribute(AwsSignerExecutionAttribute.AWS_CREDENTIALS);
97+
Region signingRegion =
98+
executionAttributes.getAttribute(AwsSignerExecutionAttribute.SIGNING_REGION);
99+
100+
if (credentials != null) {
101+
String accessKeyId = credentials.accessKeyId();
102+
if (accessKeyId != null) {
103+
currentSpan.setAttribute(AWS_AUTH_ACCESS_KEY, accessKeyId);
104+
}
105+
}
106+
107+
if (signingRegion != null) {
108+
String region = signingRegion.toString();
109+
currentSpan.setAttribute(AWS_AUTH_REGION, region);
110+
}
111+
112+
AwsSdkRequest awsSdkRequest = AwsSdkRequest.ofSdkRequest(request);
113+
if (awsSdkRequest != null) {
114+
executionAttributes.putAttribute(ADOT_AWS_SDK_REQUEST_ATTRIBUTE, awsSdkRequest);
115+
fieldMapper.mapToAttributes(request, awsSdkRequest, currentSpan);
116+
if (awsSdkRequest.type() == BEDROCKRUNTIME) {
117+
currentSpan.setAttribute(GEN_AI_SYSTEM, GEN_AI_SYSTEM_BEDROCK);
118+
}
119+
}
120+
} catch (Throwable throwable) {
121+
// ignore
122+
}
123+
}
124+
}
125+
126+
/**
127+
* This method coordinates the response attribute mapping process. This is the latest point we can
128+
* obtain the Sdk Response before span completion in upstream's afterExecution. This ensures we
129+
* capture attributes from the final, fully modified response after all upstream interceptors have
130+
* processed it. We use this hook to extract the ADOT AWS attributes from the Sdk Response and map
131+
* them to the span via the FieldMapper.
132+
*
133+
* <p>Upstream's last Sdk Response modification before span closure: @see <a
134+
* href="https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/release/v2.11.x/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java#L348">reference</a>
135+
*/
32136
@Override
33137
public SdkResponse modifyResponse(
34138
Context.ModifyResponse context, ExecutionAttributes executionAttributes) {
35139

140+
if (captureExperimentalSpanAttributes) {
141+
Span currentSpan = Span.current();
142+
AwsSdkRequest sdkRequest = executionAttributes.getAttribute(ADOT_AWS_SDK_REQUEST_ATTRIBUTE);
143+
144+
if (sdkRequest != null) {
145+
fieldMapper.mapToAttributes(context.response(), sdkRequest, currentSpan);
146+
executionAttributes.putAttribute(ADOT_AWS_SDK_REQUEST_ATTRIBUTE, null);
147+
}
148+
}
149+
36150
return context.response();
37151
}
38152
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v2_2;
17+
18+
import static io.opentelemetry.api.common.AttributeKey.stringKey;
19+
20+
import io.opentelemetry.api.common.AttributeKey;
21+
22+
final class AwsExperimentalAttributes {
23+
static final AttributeKey<String> AWS_BUCKET_NAME = stringKey("aws.bucket.name");
24+
static final AttributeKey<String> AWS_QUEUE_URL = stringKey("aws.queue.url");
25+
static final AttributeKey<String> AWS_QUEUE_NAME = stringKey("aws.queue.name");
26+
static final AttributeKey<String> AWS_STREAM_NAME = stringKey("aws.stream.name");
27+
static final AttributeKey<String> AWS_STREAM_ARN = stringKey("aws.stream.arn");
28+
static final AttributeKey<String> AWS_TABLE_NAME = stringKey("aws.table.name");
29+
static final AttributeKey<String> AWS_GUARDRAIL_ID = stringKey("aws.bedrock.guardrail.id");
30+
static final AttributeKey<String> AWS_GUARDRAIL_ARN = stringKey("aws.bedrock.guardrail.arn");
31+
static final AttributeKey<String> AWS_AGENT_ID = stringKey("aws.bedrock.agent.id");
32+
static final AttributeKey<String> AWS_DATA_SOURCE_ID = stringKey("aws.bedrock.data_source.id");
33+
static final AttributeKey<String> AWS_KNOWLEDGE_BASE_ID =
34+
stringKey("aws.bedrock.knowledge_base.id");
35+
36+
// TODO: Merge in gen_ai attributes in opentelemetry-semconv-incubating once upgrade to v1.26.0
37+
static final AttributeKey<String> GEN_AI_MODEL = stringKey("gen_ai.request.model");
38+
static final AttributeKey<String> GEN_AI_SYSTEM = stringKey("gen_ai.system");
39+
40+
static final AttributeKey<String> GEN_AI_REQUEST_MAX_TOKENS =
41+
stringKey("gen_ai.request.max_tokens");
42+
43+
static final AttributeKey<String> GEN_AI_REQUEST_TEMPERATURE =
44+
stringKey("gen_ai.request.temperature");
45+
46+
static final AttributeKey<String> GEN_AI_REQUEST_TOP_P = stringKey("gen_ai.request.top_p");
47+
48+
static final AttributeKey<String> GEN_AI_RESPONSE_FINISH_REASONS =
49+
stringKey("gen_ai.response.finish_reasons");
50+
51+
static final AttributeKey<String> GEN_AI_USAGE_INPUT_TOKENS =
52+
stringKey("gen_ai.usage.input_tokens");
53+
54+
static final AttributeKey<String> GEN_AI_USAGE_OUTPUT_TOKENS =
55+
stringKey("gen_ai.usage.output_tokens");
56+
57+
static final AttributeKey<String> AWS_STATE_MACHINE_ARN =
58+
stringKey("aws.stepfunctions.state_machine.arn");
59+
60+
static final AttributeKey<String> AWS_STEP_FUNCTIONS_ACTIVITY_ARN =
61+
stringKey("aws.stepfunctions.activity.arn");
62+
63+
static final AttributeKey<String> AWS_SNS_TOPIC_ARN = stringKey("aws.sns.topic.arn");
64+
65+
static final AttributeKey<String> AWS_SECRET_ARN = stringKey("aws.secretsmanager.secret.arn");
66+
67+
static final AttributeKey<String> AWS_LAMBDA_NAME = stringKey("aws.lambda.function.name");
68+
69+
static final AttributeKey<String> AWS_LAMBDA_ARN = stringKey("aws.lambda.function.arn");
70+
71+
static final AttributeKey<String> AWS_LAMBDA_RESOURCE_ID =
72+
stringKey("aws.lambda.resource_mapping.id");
73+
74+
static final AttributeKey<String> AWS_TABLE_ARN = stringKey("aws.table.arn");
75+
76+
static final AttributeKey<String> AWS_AUTH_ACCESS_KEY = stringKey("aws.auth.account.access_key");
77+
78+
static final AttributeKey<String> AWS_AUTH_REGION = stringKey("aws.auth.region");
79+
80+
static boolean isGenAiAttribute(String attributeKey) {
81+
return attributeKey.equals(GEN_AI_REQUEST_MAX_TOKENS.getKey())
82+
|| attributeKey.equals(GEN_AI_REQUEST_TEMPERATURE.getKey())
83+
|| attributeKey.equals(GEN_AI_REQUEST_TOP_P.getKey())
84+
|| attributeKey.equals(GEN_AI_RESPONSE_FINISH_REASONS.getKey())
85+
|| attributeKey.equals(GEN_AI_USAGE_INPUT_TOKENS.getKey())
86+
|| attributeKey.equals(GEN_AI_USAGE_OUTPUT_TOKENS.getKey());
87+
}
88+
89+
private AwsExperimentalAttributes() {}
90+
}

0 commit comments

Comments
 (0)