AWS X-Ray — รายละเอียดเพิ่มเติม
คืออะไร
AWS X-Ray เป็นบริการ distributed tracing สำหรับวิเคราะห์ microservices
คุณสมบัติหลัก
- Visual analysis ของ application architecture
- ตรวจจับ performance bottlenecks และ errors
- แสดง service map ของ dependencies ทั้งหมด
Instrumentation
- ใช้ X-Ray SDK ใน application code
- หรือใช้ X-Ray Daemon รับ data แล้วส่งไป X-Ray service
- รองรับ: Java, Node.js, Python, Go, .NET, Ruby
Concepts
- Segments — ข้อมูลจาก service หนึ่ง
- Subsegments — รายละเอียดเพิ่มเติมภายใน segment (เช่น DB calls, HTTP calls)
- Traces — รวม segments จากทุก services ที่ request ผ่าน
- Annotations — key-value pairs สำหรับ index และ filter traces
- Metadata — key-value pairs ไม่ถูก index (เก็บข้อมูลเพิ่มเติม)
Sampling Rules
- กำหนดว่าจะ trace กี่ % ของ requests
- Default: 1 request/วินาที + 5% ของ requests เพิ่มเติม
- Custom rules สำหรับ specific paths/services
X-Ray API
PutTraceSegments— upload segment dataPutTelemetryRecords— upload telemetryGetTraceSummaries— ดู trace summariesBatchGetTraces— ดู trace detailsGetServiceGraph— ดู service map
X-Ray กับ Services อื่น
- ECS — ใช้ X-Ray daemon container เป็น sidecar
- Elastic Beanstalk — enable X-Ray ใน console/config
- Lambda — enable Active Tracing ใน function config
- API Gateway — enable tracing ใน stage settings