-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: AWS SQS MD5 Hash Mismatch (#1572)
- Loading branch information
Showing
13 changed files
with
184 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/OpenTelemetry.Instrumentation.AWS/Implementation/AWSPropagatorPipelineHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Amazon.Runtime; | ||
using Amazon.Runtime.Internal; | ||
using OpenTelemetry.Context.Propagation; | ||
using OpenTelemetry.Extensions.AWS.Trace; | ||
|
||
namespace OpenTelemetry.Instrumentation.AWS.Implementation; | ||
|
||
/// <summary> | ||
/// Uses <see cref="AWSXRayPropagator"/> to inject the current Activity Context and | ||
/// Baggage into the outgoing AWS SDK Request. | ||
/// <para /> | ||
/// Must execute after the AWS SDK has marshalled (ie serialized) | ||
/// the outgoing request object so that it can work with the <see cref="IRequest"/>'s | ||
/// <see cref="IRequest.Headers"/>. | ||
/// </summary> | ||
internal class AWSPropagatorPipelineHandler : PipelineHandler | ||
{ | ||
private static readonly AWSXRayPropagator AwsPropagator = new(); | ||
|
||
private static readonly Action<IDictionary<string, string>, string, string> Setter = (carrier, name, value) => | ||
{ | ||
carrier[name] = value; | ||
}; | ||
|
||
/// <summary> | ||
/// Rely on the the <see cref="AWSTracingPipelineHandler.Activity"/> for retrieving the current | ||
/// context. | ||
/// </summary> | ||
private readonly AWSTracingPipelineHandler tracingPipelineHandler; | ||
|
||
public AWSPropagatorPipelineHandler(AWSTracingPipelineHandler tracingPipelineHandler) | ||
{ | ||
this.tracingPipelineHandler = tracingPipelineHandler; | ||
} | ||
|
||
public override void InvokeSync(IExecutionContext executionContext) | ||
{ | ||
this.ProcessBeginRequest(executionContext); | ||
|
||
base.InvokeSync(executionContext); | ||
} | ||
|
||
public override async Task<T> InvokeAsync<T>(IExecutionContext executionContext) | ||
{ | ||
this.ProcessBeginRequest(executionContext); | ||
|
||
return await base.InvokeAsync<T>(executionContext).ConfigureAwait(false); | ||
} | ||
|
||
private void ProcessBeginRequest(IExecutionContext executionContext) | ||
{ | ||
if (this.tracingPipelineHandler.Activity == null) | ||
{ | ||
return; | ||
} | ||
|
||
AwsPropagator.Inject( | ||
new PropagationContext(this.tracingPipelineHandler.Activity.Context, Baggage.Current), | ||
executionContext.RequestContext.Request.Headers, | ||
Setter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.