Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Ruby

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

การตั้งค่า custom metrics เป็น easy way เพื่อได้ instant insights เข้าไปในข้อมูลที่คุณต้องการ (โดยไม่ต้อง sift through log lines หรือ struggle กับ complicated reporting tools) Supplement critical monitoring data ของแอปพลิเคชันโดยการ track meaningful metrics เพื่อ quickly identify และ resolve potential issues

ในบล็อกโพสต์นี้ เราจะแสดงวิธี setup และใช้ custom metrics เพื่อ remove monitoring blind spots เราจะ demonstrate ว่าคุณสามารถใช้ custom metrics ร่วมกับ suite ของ monitoring tools เพื่อ better understand performance ของแอปพลิเคชัน

Custom Metrics คืออะไร?

เมื่อมันมาถึง metrics AppSignal โดย default tracks critical data เช่น error rates, response times และ throughput เราใช้ metrics เหล่านี้ monitor แอปพลิเคชันและแจ้งเตือนเมื่อแอปพลิเคชันประสบ performance issues

Custom metrics อนุญาตให้คุณ visualize และ track application data ใดๆ ที่คุณอยากให้ deeper insights เข้า performance ของแอปพลิเคชันโดย relating additional contexts — เช่น active user counts หรือ job-specific processing times คุณสามารถสร้าง dashboards ใน AppSignal เพื่อ track custom metrics alongside critical metrics เช่น throughput หรือ database size

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

การวัด Metrics ของคุณ

เมื่อส่ง metrics ไป AppSignal สิ่งสำคัญคือพิจารณาว่าคุณอยาก measure พวกมันอย่างไร AppSignal เสนอสาม measurement methods:

AppSignal ให้ methods และ functions ช่วยคุณ easily track custom metrics โดยใช้ appropriate form of measurement

มาลอง imagine เรากำลัง monitor webshop เราจะแสดงว่าคุณสามารถใช้ gauge, counter และ distribution measurements เพื่อ track specific data points

Gauge

สำหรับ context ใส่ why แอปพลิเคชันของเราอาจ more หรือ less performant than usual มาดูว่ามี active shoppers กี่คน currently using แอปพลิเคชัน เราจะใช้ gauge measure เพื่อ report active user count ทุกครั้งที่ new user session ถูกสร้างในแอปพลิเคชัน

เพื่อทำนี้ เราสามารถสร้าง minutely probe mechanism ที่ส่ง custom metrics ไป AppSignal periodically เราสามารถใช้ probe นี้ record ว่ามี shopping carts กี่อันที่ updated ภายในนาทีล่าสุด และส่งข้อมูลนี้ไป AppSignal ภายใต้ label active_shoppers โดยใช้ method set_gauge ตัวอย่างเช่น:

Ruby


คุณสามารถอ่าน Ruby documentation ของเราสำหรับข้อมูลเพิ่มเติมเกี่ยวกับ minutely probes

Elixir


คุณสามารถอ่าน Elixir documentation ของเราสำหรับข้อมูลเพิ่มเติมเกี่ยวกับ minutely probes

Node.js


คุณสามารถอ่าน Node.js documentation ของเราสำหรับข้อมูลเพิ่มเติมเกี่ยวกับ minutely probes

เมื่อ configured แล้ว เราสามารถสร้าง chart ใน AppSignal เพื่อ track active shoppers กี่คนที่ใช้แอปพลิเคชัน:

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

ด้วยข้อมูลนี้ เราสามารถ quickly infer ว่า webshop ของเรา perform อย่างไร based on approximate number ของ people actively using site หากเราสังเกตเห็น particularly high count และคาดการณ์ performance issues เราสามารถ take measures ให้แน่ใจว่าแอปพลิเคชัน available

Counter

ด้วย counters เราสามารถ track ว่าสิ่งใดเกิดขึ้นบ่อยแค่ไหนในแอปพลิเคชัน Feature นี้ handy ใน scenarios ที่คุณต้อง monitor frequency ของ certain events หรือ actions over time — ตัวอย่างเช่น user 完成 action กี่ครั้ง เช่นเพิ่ม item ไป cart

สมมติเราอยากเข้าใจว่าแอปพลิเคชัน invoicing users บ่อยแค่ไหน เพื่อทำนี้ เราต้อง increment counter ทุกครั้งที่ invoice ถูกสร้าง

ใช้ method increment_counter ใน Ruby และ Elixir:


และ function incrementCounter ใน Node.js:


เมื่อ setup แล้ว เราสามารถ track ว่าแอปพลิเคชัน generate invoices กี่อันใน AppSignal:

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

ماذا لوเรา track additional related data points เช่น orders placed และสังเกตว่า metrics ไม่ tracking against each other as expected? แล้วเราสามารถ investigate invoicing และ ordering logic และ potentially locate และ fix critical issues ก่อนที่จะ impact หลาย customers

Distribution

คุณสามารถใช้ custom metrics เพื่อ record data measurements เช่น response time หรือ background job duration การ track metrics เหล่านี้ช่วยให้คุณ identify poorly performing background jobs หรือ API endpoints ซึ่งอาจ negatively impact user experience

เราอยากเห็น average time ที่แอปพลิเคชันใช้รัน order confirmation job เพราะมัน vital customers receive email นี้ภายใน minutes ของการ purchase

เพื่อทำนี้ เราใช้ method add_distribution_value:

Ruby


Elixir


Node.js


เมื่อทำเสร็จ เราสามารถ track average time confirm order job ใช้ในการ complete ใน AppSignal เราจะ notice หากมัน performing slower than expected ก่อน users ทำ ให้เรา proactively keep แอปพลิเคชัน available และ scalable

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

Custom Dashboards สำหรับ Custom Metrics

ขอบคุณ intuitive UI ของเรา คุณสามารถเริ่ม track custom metrics ในนาที

คุณสามารถใช้ปุ่ม "Add dashboard" ใน Dashboard navigation เพื่อสร้าง dashboard ใหม่ คลิกปุ่ม "Add graph" เพื่อเริ่มสร้าง graphs ด้วย Graph Builder

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

เมื่อสร้าง graph คุณสามารถ select metrics และ tags ที่คุณอยาก chart และ config graph's legends และ labels เมื่อเสร็จ คุณจะทันทีเห็น graph display current metric data สำหรับ specified period of time

ทำไม Metrics ถึงสำคัญ

ในขณะที่ logging เป็น fantastic solution ช่วยคุณ debug และ troubleshoot application performance issues หลัง พวกมัน occurred metrics สามารถช่วยคุณ prevent future issues ก่อน customers สังเกตอะไรก็ตาม ด้วย custom metrics คุณสามารถ:

  • Concentrate on what matters (โฟกัสที่สำคัญ): Track specific data points ในแอปพลิเคชัน accurately และได้ focused insights โดยไม่ต้อง filter through large amounts ของ logging metadata หรือ incident lists
  • Get down to business (เข้าสู่ธุรกิจ): เข้าใจ performance ของแอปพลิเคชันจาก business perspective และ quickly track critical data เช่น active user counts, KPIs หรือ daily sales
  • Streamline your logging (ทำให้ logging streamlined): Logging 'everything everywhere all at once' เป็น unsustainable ด้วย custom metrics คุณสามารถ track essential data efficiently และใช้ logs เพื่อ investigate cause ของ incidents only logging data ที่ necessary สำหรับ troubleshooting และ debugging
  • Work proactively, not reactively (ทำงาน proactive ไม่ reactive): Set custom triggers เพื่อแจ้งเตือนหากแอปพลิเคชันใช้เวลานานเกินไปส่ง invoices ให้ users หรือประสบ higher volume of active users than usual Warnings เหล่านี้อนุญาตให้คุณ proactively investigate และ resolve issue ก่อนที่จะ impact customers

Dive Deeper Into Custom Metrics

พร้อมที่จะ get the most out of แอปพลิเคชัน metrics? บล็อกโพสต์นี้ cover just a small slice ของสิ่งที่ possible ด้วย custom metrics ใน AppSignal Documentation ของเราเกี่ยวกับ custom metrics outline ทุกอย่างที่คุณต้องรู้

หากคุณต้องการ help มี questions เกี่ยวกับ metrics หรือ anything else AppSignal หรือ monitoring related คุณสามารถ contact เราได้ตลอด

AppSignal's custom metrics เพียงหนึ่งใน many developer-driven features ที่ช่วยให้คุณ monitor แอปพลิเคชัน Developers ยัง enjoy ใช้ monitoring ของเราเพราะเรามี:

  • อินเทอร์เฟซที่เข้าใจง่ายและนำทางสะดวก
  • ราคาที่เรียบง่ายและคาดการณ์ได้
  • Developer-to-developer support

หากคุณใหม่กับ AppSignal จำได้ว่าให้ขอ free stroopwafels บางส่วนจากเรา! พวกมันอร่อยเกือบเท่ากับการมี metrics ทั้งหมดของแอปพลิเคชันอยู่ที่นิ้วมือ 😉🍪

ติดตาม Custom Metrics ใน AppSignal เพื่อข้อมูลเชิงลึกทันทีและ可操作

Connor James

Developer Marketing Manager ที่ AppSignal ผู้ติดพอดแคสต์ รัก cannoli จนคิดจะเปลี่ยนชื่อเป็น Connoli เขาคิดว่ามีตัว 'u' ในคำว่า color คุณอาจพบเขาบนไมค์ บนเวที หรือนอนบนโซฟาเมื่อเขาออฟดิวตี้

บทความทั้งหมดโดย Connor James