AWS X-Ray
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Creating Additional Subsegments

In the user model class, the application manually creates subsegments to group all downstream calls made within the saveUser function and adds metadata.

Example src/main/java/scorekeep/UserModel.java - Custom Subsegments

import com.amazonaws.xray.AWSXRay; import com.amazonaws.xray.entities.Subsegment; ... public void saveUser(User user) { // Wrap in subsegment Subsegment subsegment = AWSXRay.beginSubsegment("## UserModel.saveUser"); try { mapper.save(user); } catch (Exception e) { subsegment.addException(e); throw e; } finally { AWSXRay.endSubsegment(); } }