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

Open
amol-kashetwar-cko opened this issue Nov 6, 2024 · 2 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.

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

2 participants