Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Amazon.SQS.AmazonSQSException: Attribute MD5 hash mismatch thrown on 1.1.0-beta.6 version when SQS message had attribute #2304

Closed
amol-kashetwar-cko opened this issue Nov 6, 2024 · 7 comments
Labels
bug Something isn't working comp:instrumentation.aws Things related to OpenTelemetry.Instrumentation.AWS

Comments

@amol-kashetwar-cko
Copy link

amol-kashetwar-cko commented Nov 6, 2024

Component

OpenTelemetry.Instrumentation.AWS

Package Version

Package Name Version
OpenTelemetry.Instrumentation.AWS 1.1.0-beta.6

Runtime Version

net8.0

Description

When SQS messages have attribute(s), Amazon.SQS.AmazonSQSException: Attribute MD5 hash mismatch thrown on latest version.

Steps to Reproduce

Sample test on Lambda

`using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon.Lambda.Core;
using OpenTelemetry;
using OpenTelemetry.Instrumentation.AWSLambda;
using OpenTelemetry.Trace;
using Amazon.SQS;
using Amazon.SQS.Model;

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

namespace LambdaTest
{
public class LambdaHandlerSQS
{
private IAmazonSQS _sqsClient;
private readonly Tracer _tracer;

    public async Task handleRequest(ILambdaContext context)
    {
        TracerProvider tracerProvider = Sdk.CreateTracerProviderBuilder()
        .AddAWSLambdaConfigurations(options => options.DisableAwsXRayContextExtraction = true)
        .AddAWSInstrumentation()
        .AddConsoleExporter()
        .SetSampler<AlwaysOnSampler>()
        .Build();
        
        await AWSLambdaWrapper.TraceAsync(
            tracerProvider, 
            async (input,  ctx) => await SendtoSQSAsync(ctx), 
            default(object), 
            context);
    }

    private async Task SendtoSQSAsync(ILambdaContext context)
    {
        _sqsClient = new AmazonSQSClient();

        var tasks = Enumerable.Range(1, 100).ToList().Select(async i =>
        {
            try
            {
                // Send message to the SQS queue
                var messageAttributes = new Dictionary<string, MessageAttributeValue>
                {
                    { "Attribute1", new MessageAttributeValue { StringValue = "Value1", DataType = "String" } },
                    { "Attribute2", new MessageAttributeValue { StringValue = "Value2", DataType = "String" } },
                };
                var sendMessageRequest = new SendMessageRequest
                {
                    QueueUrl = "https://sqs.us-east-1.amazonaws.com/something/TestOTel",
                    MessageBody = "This is a test message",
                    MessageAttributes = messageAttributes
                };

                var response = await _sqsClient.SendMessageAsync(sendMessageRequest);
                context.Logger.LogLine($"Message sent with ID: {response.MessageId}");

                return response.MessageId;
            }
            catch (Exception ex)
            {
                context.Logger.LogLine($"Error sending message: {ex.Message}");
                throw;
            }
        });
        await Task.WhenAll(tasks);
        
    }
}

}`

Expected Result

Messages should get sent to queue without exception

Actual Result

Amazon.SQS.AmazonSQSException: Attribute MD5 hash mismatch thrown

Additional Context

No response

@amol-kashetwar-cko amol-kashetwar-cko added the bug Something isn't working label Nov 6, 2024
@github-actions github-actions bot added the comp:instrumentation.aws Things related to OpenTelemetry.Instrumentation.AWS label Nov 6, 2024
Copy link
Contributor

github-actions bot commented Nov 6, 2024

Tagging component owner(s).

@srprash @ppittle @muhammad-othman @rypdal @Oberon00

@muhammad-othman
Copy link
Member

Hi @amol-kashetwar-cko,
I believe this bug is similar to #2108, which was fixed in #2137 but is still pending release.

@mumby0168
Copy link

Morning, I am also facing this issue, is there a timeline for when the release will happen @muhammad-othman ?

@JoeStead
Copy link

Would also quite like to know when this will be released. Is there an alpha build we can use in the interim? Is there anything we can do to try and expedite the release of this fix?

@muhammad-othman
Copy link
Member

Sorry @mumby0168 I've missed your earlier comment.
We've encountered some versioning conflicts with related packages. I'll reach out to the team to ensure this is prioritized. I'll provide an update soon on a timeline for the release.

@cdcaskey
Copy link

The latest release does look to have resolved the issue. I can now send messages without the MD5 hash mismatch exception

@Kielek
Copy link
Contributor

Kielek commented Nov 25, 2024

Closing. See previous comment

@Kielek Kielek closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working comp:instrumentation.aws Things related to OpenTelemetry.Instrumentation.AWS
Projects
None yet
Development

No branches or pull requests

6 participants