Skip to content

Commit e2b960f

Browse files
committed
fix duplicate interceptor test
1 parent 82c064d commit e2b960f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public SdkRequest modifyRequest(
142142
io.opentelemetry.context.Context parentOtelContext = io.opentelemetry.context.Context.current();
143143
SdkRequest request = context.request();
144144

145+
// the request has already been modified, duplicate interceptor?
146+
if (executionAttributes.getAttribute(SDK_REQUEST_ATTRIBUTE) != null) {
147+
return request;
148+
}
149+
145150
// Ignore presign request. These requests don't run all interceptor methods and the span created
146151
// here would never be ended and scope closed.
147152
if (executionAttributes.getAttribute(AwsSignerExecutionAttribute.PRESIGNER_EXPIRATION)
@@ -229,6 +234,11 @@ public SdkRequest modifyRequest(
229234
@Override
230235
public void afterMarshalling(
231236
Context.AfterMarshalling context, ExecutionAttributes executionAttributes) {
237+
// the request has already been modified, duplicate interceptor?
238+
if (executionAttributes.getAttribute(SCOPE_ATTRIBUTE) != null) {
239+
return;
240+
}
241+
232242
io.opentelemetry.context.Context otelContext = getContext(executionAttributes);
233243
if (otelContext != null
234244
&& executionAttributes

0 commit comments

Comments
 (0)