newrelic-dotnet-agent
newrelic-dotnet-agent copied to clipboard
NewRelic.OpenTracing.AmazonLambda.Tracer v1.3.0 breaks DT if "newrelic" header doesn't exist in record.Body
Current Behavior
The bug occurs on this line: https://github.com/newrelic/newrelic-dotnet-agent/blob/2ba99ea91ac20f79af40259e485949c6b3b1aac3/src/AwsLambda/AwsLambdaWrapper/IOParser.cs#L131
The if-statement is checking if the SQS message coming into the lambda contains an SNS message inside of it, and is also supposed to be looking for the "newrelic" header, in case a distributed trace had already been started and needed to be continued. However, this if-statement fails to actually check if the SQS message body contains the string "newrelic" and just blindly assumes it is there. This will cause the code inside the if-statement to get a random string added as the newrelic header value, which in turns blows up the trace.
Expected Behavior
Only process the SQS message if it contains and SNS message and a "newrelic" header.
To fix:
Add && record.Body.IndexOf("newrelic") > -1
to the end of the if-statement to make sure that "newrelic" is actually there in the SQS message body.
Or possibly && record.Body.ContainsKey(NEWRELIC_TRACE_HEADER)
Environment
- .NET Lambda using NewRelic.OpenTracing.AmazonLambda.Tracer v1.3.0
- Triggered by an SQS queue which has messages from an SNS subscription
Additional Details
This code has not changed in 2 years. Is it possible this bug has existed the whole time or could it be related to the implementation for this specific use case? https://github.com/newrelic/newrelic-dotnet-agent/blame/2ba99ea91ac20f79af40259e485949c6b3b1aac3/src/AwsLambda/AwsLambdaWrapper/IOParser.cs#L131
Hi @keegoid-nr, thanks for letting us know about this issue. We're in the process of prioritizing bug fixes for an upcoming (late December) bug smash milestone and we discussed this issue in a team meeting this morning, so it's definitely on our radar. Since it looks like you've already done all the root cause analysis and provided a fix, it should make it easier to commit to fixing this. Thanks!
https://issues.newrelic.com/browse/NEWRELIC-3608
Jira CommentId: 122739 Commented by angelatan:
Hello @keegoid-nr. The .NET agent Lambda offering was designed at the time with the open tracing standard in mind. It was tested to function with .NET Core 3.1. Microsoft EOL of .NET Core 3.1 is Dec 13, 2022. Open Trace standard has been rolled into OpenTelemetry and is no longer active. Based on these factors, we have decided not to address this bug.
This issue won't be actioned.