Skip to content

Instantly share code, notes, and snippets.

@honewatson
Last active August 15, 2024 09:56
Show Gist options
  • Save honewatson/d1600dd1250deed35c326fbeabb77cdc to your computer and use it in GitHub Desktop.
Save honewatson/d1600dd1250deed35c326fbeabb77cdc to your computer and use it in GitHub Desktop.
AppDynamics SQS Custom Correlation Example

https://docs.appdynamics.com/display/PRO45/Java+Backend+Detection

"Correlating SQS traffic requires you to configure the continuation entry point for the SQS message."

What this means is you must correlate the consumer java agent to extract the singularity header.

Below is an example which assumes there is an object with getter getSingularityHeader.

The object with getSingularityHeader is the first argument of a class/method com.example.service.sqs.SqsSubscriber.processMessage

SqsSubscriber.processMessage is called with in a class/method com.example.service.sqs.SqsSubscriber.processMessage

<activities>
<consumer activity-demarcator="true">
<!--
This is the boundary of the continuing transaction and also encloses the point where correlation metadata is read
-->
<instrumentation>
<class-name>com.example.service.sqs.SqsSubscriber</class-name>
<method-name>subscribeToSQSDirectly</method-name>
<match-type>MATCHES_CLASS</match-type>
</instrumentation>
<correlation>
<!--
This is where instrumentation to get payload bearing correlation metadata.
This instrumentation point is inside of transaction boundary specified above
-->
<instrumentation>
<class-name>com.example.service.sqs.SqsSubscriber</class-name>
<method-name>processMessage</method-name>
<match-type>MATCHES_CLASS</match-type>
</instrumentation>
<!--
How to get payload ?
-->
<payload-pointer>
<data-gatherer-type>RETURN</data-gatherer-type>
<getter-chain>this</getter-chain>
<transformer-type>GETTER_METHODS</transformer-type>
</payload-pointer>
<!--
How to extract correlation metadata from payload
-->
<payload-operation>
<access-type>method</access-type>
<access-method>getSingularityHeader</access-method>
</payload-operation>
</correlation>
</consumer>
</activities>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment