0Pricing
System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) · درس

سمات الامتداد والأحداث والحالة

تعلّم إثراء امتدادات التتبع بسمات ذات معنى، وتسجيل الأحداث الموقّتة، وتعيين حالة الامتداد، لتكون آثار التتبع تشخيصية لا مجرد بيانات توقيت.

سمات الامتداد والأحداث والحالة درس مجاني في System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Beyond Timing

A span knows its duration automatically, but raw timing is rarely enough. Enriching spans with attributes, events, and status makes traces tell a story.

Span Attributes

Attributes are key-value pairs that add context to a span, like the route handled or the number of rows returned.

span.set_attribute("http.route", "/orders/:id")
span.set_attribute("db.rows", 42)

Use Conventions

Prefer standard semantic-convention keys for common data so backends understand them. Use custom keys only for domain-specific context.

standard: http.response.status_code
custom: order.tier

Keep Attributes Bounded

Like metric labels, avoid high-cardinality or huge values. Do not stuff entire payloads into an attribute.

  • Good: order count, region
  • Bad: full request body, raw stack trace as attribute

Span Events

An event is a timestamped annotation inside a span marking something that happened at a moment, like a retry or cache miss.

span.add_event("cache.miss", { "key": "user:42" })

Recording Exceptions

Exceptions are recorded as a special event capturing the type, message, and stack, so failures show up in the trace timeline.

try:
    do_work()
except Exception as e:
    span.record_exception(e)

Span Status

Status tells whether the operation succeeded. The default is Unset; set Error on failure so backends can highlight broken spans.

span.set_status(StatusCode.ERROR, "payment declined")

Status vs Recording Exceptions

Recording an exception adds detail but does not by itself mark the span failed. Always also set the status to Error.

span.record_exception(e)
span.set_status(StatusCode.ERROR)

Attributes vs Events

Use attributes for facts true for the whole span; use events for things that happen at a point in time within it.

Naming Spans Well

Span names should be low cardinality, describing the operation type, not the specific instance. Put the variable part in attributes.

name: "GET /orders/:id"   (good)
name: "GET /orders/48213" (bad)

A Well-Formed Span

A diagnostic span has a clean name, a few bounded attributes, events for notable moments, and an accurate status.

Quick Check

Pick the correct statement about span status.

Recap

You learned to enrich spans with bounded attributes (preferring semantic conventions), to mark point-in-time moments and failures with events and record_exception, and to set status to Error explicitly. Low-cardinality span names plus rich context turn traces into real diagnostics.

الأسئلة الشائعة

هل درس «سمات الامتداد والأحداث والحالة» مجاني؟

نعم — نص درس «سمات الامتداد والأحداث والحالة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)، انتقل إلى CoddyKit PRO. تتضمن دورة System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 4 دروس في المجموع.

ماذا ستتعلم في «سمات الامتداد والأحداث والحالة»؟

تعلّم إثراء امتدادات التتبع بسمات ذات معنى، وتسجيل الأحداث الموقّتة، وتعيين حالة الامتداد، لتكون آثار التتبع تشخيصية لا مجرد بيانات توقيت. تتمرن على System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)؟

لا تُشترط خبرة سابقة. System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «سمات الامتداد والأحداث والحالة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) هذا؟

نعم. كل درس في System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. تقنيات التزويد التلقائي بالأدوات
  2. أفضل ممارسات التزويد اليدوي بالأدوات
  3. نشر السياق وBaggage
  4. سمات الامتداد والأحداث والحالة
← العودة إلى System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry)