Skip to content

feat: add span links to AWS SQS ReceiveMessage spans for messages with a traceparent#2706

Merged
trentm merged 3 commits intomainfrom
trentm/span-links-for-messaging
May 24, 2022
Merged

feat: add span links to AWS SQS ReceiveMessage spans for messages with a traceparent#2706
trentm merged 3 commits intomainfrom
trentm/span-links-for-messaging

Conversation

@trentm
Copy link
Copy Markdown
Member

@trentm trentm commented May 19, 2022

Refs: #2593

This is part of #2593. The change just for SQS instrumentation got large enough that I'll break it up into a few PRs: SQS, SNS, and Lambda instrumentation updates.

@trentm trentm self-assigned this May 19, 2022
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label May 19, 2022
@ghost
Copy link
Copy Markdown

ghost commented May 19, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-05-20T00:13:53.243+0000

  • Duration: 21 min 46 sec

Test stats 🧪

Test Results
Failed 0
Passed 256717
Skipped 0
Total 256717

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run module tests for <modules> : Run TAV tests for one or more modules, where <modules> can be either a comma separated list of modules (e.g. memcached,redis) or the string literal ALL to test all modules

  • run benchmark tests : Run the benchmark test only.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@trentm trentm requested a review from astorm May 19, 2022 22:12
@trentm
Copy link
Copy Markdown
Member Author

trentm commented May 19, 2022

This example SQS ReceiveMessage call received two messages, both with a traceparent message attribute:

% node examples/trace-sqs-receive-message.js us-west-2 trentm-play-queue2
SQS ReceiveMessage from region=us-west-2 queueName=trentm-play-queue2
queueUrl: https://sqs.us-west-2.amazonaws.com/627286350134/trentm-play-queue2
receiveMessage response data: {
  ResponseMetadata: { RequestId: '8fcd239b-70cf-509d-a6d2-789bc0aecca0' },
  Messages: [
    {
      MessageId: '3c9ecba1-ccc3-4705-904e-f2632585b484',
      ReceiptHandle: 'AQE...vHaqg==',
      MD5OfBody: 'ca924e32a2637b1ddcf3fb24b23c6800',
      Body: 'this is my message (5c9f48fd93dd0c67)',
      Attributes: { SentTimestamp: '1652915045801' },
      MD5OfMessageAttributes: 'b0efdcf9d89ac6f2f4eb673361da8e05',
      MessageAttributes: {
        foo: {
          StringValue: 'bar',
          StringListValues: [],
          BinaryListValues: [],
          DataType: 'String'
        },
        traceparent: {
          StringValue: '00-12345678901234567890123456789012-1234567890123456-01',
          StringListValues: [],
          BinaryListValues: [],
          DataType: 'String'
        }
      }
    },
    {
      MessageId: 'ee87cab5-53bc-4f59-84e4-1dcf35680d51',
      ReceiptHandle: 'AQEB...PiTA==',
      MD5OfBody: '64311fa38e37e6b99e7ea0cbe489e5c4',
      Body: 'this is my message (0.24334544662323276)',
      Attributes: { SentTimestamp: '1652993555068' },
      MD5OfMessageAttributes: '76c1e0849a3d2aa933d3a77947bf2b3c',
      MessageAttributes: {
        foo: {
          StringValue: 'bar',
          StringListValues: [],
          BinaryListValues: [],
          DataType: 'String'
        },
        traceparent: {
          StringValue: '00-460d51b6ed3ab96be45f2580b8016509-8ba4419207a1f2f8-01',
          StringListValues: [],
          BinaryListValues: [],
          DataType: 'String'
        }
      }
    }
  ]
}

This resulted in the following trace:

    trace f3657b
    `- transaction c18347 "receive-message" (381.782ms, outcome=unknown)
       `- span 27c6af "POST sqs.us-west-2.amazonaws.com" (123.579ms, http)
       `- span 877a05 "SQS POLL from trentm-play-queue2" (114.945ms, sqs)
       `- span 379ea4 "SQS DELETE_BATCH from trentm-play-queue2" (118.658ms, sqs)

With this span for the ReceiveMessage (note the "links"):

    {
        "span": {
            "name": "SQS POLL from trentm-play-queue2",
            "type": "messaging",
            "id": "877a056f33dfe907",
            "transaction_id": "c18347bb3232f340",
            "parent_id": "c18347bb3232f340",
            "trace_id": "f3657bea101d9082f222536abe87ce94",
            "subtype": "sqs",
            "action": "poll",
            "timestamp": 1652993569079702,
            "duration": 114.945,
            "context": {
                "destination": {
                    "service": {
                        "name": "sqs",
                        "resource": "sqs/trentm-play-queue2",
                        "type": "messaging"
                    },
                    "cloud": {
                        "region": "us-west-2"
                    }
                },
                "message": {
                    "queue": {
                        "name": "trentm-play-queue2"
                    }
                }
            },
            "sync": false,
            "outcome": "success",
            "sample_rate": 1,
            "links": [
                {
                    "trace_id": "12345678901234567890123456789012",
                    "span_id": "1234567890123456"
                },
                {
                    "trace_id": "460d51b6ed3ab96be45f2580b8016509",
                    "span_id": "8ba4419207a1f2f8"
                }
            ]
        }
    }

Copy link
Copy Markdown
Contributor

@astorm astorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No notes, does the thing. Approving.

@trentm trentm merged commit 10c287a into main May 24, 2022
@trentm trentm deleted the trentm/span-links-for-messaging branch May 24, 2022 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-nodejs Make available for APM Agents project planning.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants