Skip to content

Commit

Permalink
Make sure we remove the DSM propagation header from SQS attributes (#…
Browse files Browse the repository at this point in the history
…3312)

* Make sure we remove the DSM propagation header from SQS attributes

SQS has a hard limit of 10, so we have to consolidate them into a single header

* Update integration test to check for removal of propagation headers

* whitespace
  • Loading branch information
andrewlock authored Oct 6, 2022
1 parent 3a87cd7 commit 57f30cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Datadog.Trace.DataStreamsMonitoring;
using Datadog.Trace.Propagators;

namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.AWS.SQS
Expand Down Expand Up @@ -44,7 +45,9 @@ public static void InjectHeadersIntoMessage<TMessageRequest>(IContainsMessageAtt
// Make sure we do not propagate any other datadog header here in the rare cases where users would have added them manually
foreach (var attribute in carrier.MessageAttributes.Keys)
{
if (attribute is string attributeName && attributeName.StartsWith("x-datadog", StringComparison.OrdinalIgnoreCase))
if (attribute is string attributeName &&
(attributeName.StartsWith("x-datadog", StringComparison.OrdinalIgnoreCase)
|| attributeName.Equals(DataStreamsContextPropagator.PropagationKey, StringComparison.OrdinalIgnoreCase)))
{
#if !NETCOREAPP2_1_OR_GREATER
attributesToRemove ??= new List<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Datadog.Trace.DataStreamsMonitoring;
/// </summary>
internal class DataStreamsContextPropagator
{
private const string PropagationKey = "dd-pathway-ctx";
internal const string PropagationKey = "dd-pathway-ctx";

public static DataStreamsContextPropagator Instance { get; } = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static async Task SendMessagesWithInjectedHeadersAsync(AmazonSQSClient s
{ "x-datadog-7", new MessageAttributeValue(){ DataType = "String", StringValue = "value7" } },
{ "x-datadog-8", new MessageAttributeValue(){ DataType = "String", StringValue = "value8" } },
{ "x-datadog-9", new MessageAttributeValue(){ DataType = "String", StringValue = "value9" } },
{ "x-datadog-10", new MessageAttributeValue(){ DataType = "String", StringValue = "value10" } },
{ "dd-pathway-ctx", new MessageAttributeValue(){ DataType = "String", StringValue = "value10" } },
};

// Send one message, receive it, and parse it for its headers
Expand Down

0 comments on commit 57f30cd

Please sign in to comment.