aws / aws-xray-sdk-java

The official AWS X-Ray Recorder SDK for Java.
Apache License 2.0
96 stars 99 forks source link

subsegment cloudwatch latency metrics #368

Open girotomas opened 1 year ago

girotomas commented 1 year ago

There is support to emit cloudwatch metrics per xray segment: https://docs.amazonaws.cn/en_us/xray/latest/devguide/xray-sdk-java-monitoring.html (Although I was not able to get it to work)

Feature Request:

Be able to emit latency metrics to cloudwatch on a SUBSEGMENT basis. Not for each segment, but also for the subsegments.

I would be able to work on this issue given guidance on how to do it.

Tagging people related to MetricsSegmentListener: @willarmiros @c1tadel

willarmiros commented 1 year ago

Hi @girotomas - yes you can extend the MetricsSegmentListener using the same hooks but for subsegments instead of segments. See here for the SegmentListener interface, which includes subsegment creation/ending hooks: https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/listeners/SegmentListener.java

And the MetricsSegmentListener which creates metrics based on segments (the logic would be the same, but for subsegments): https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-metrics/src/main/java/com/amazonaws/xray/metrics/MetricsSegmentListener.java