0Pricing
MCP Academy · درس

تتبّع استدعاء أداة من البداية إلى النهاية

تابعوا طلبًا واحدًا عبر كامل المكدس.

تتبّع استدعاء أداة من البداية إلى النهاية درس مجاني في MCP Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MCP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MCP Academy 4 دروس في المجموع.

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

Following One Call

A single tool call may touch your server, a database, and an API. Tracing stitches those hops into one timeline so you see the whole journey. 🧵

Traces and Spans

A trace is the full request; a span is one step inside it. Each span records a name, a start, and a duration, and spans nest like a tree.

The Trace ID

Every span in one request shares a single trace ID. That shared id is what lets a tool reconstruct exactly which steps belonged together.

Parent and Child Spans

Spans link through a parent ID. The tool call is the parent; the database query and API call become its children, forming the timeline tree.

OpenTelemetry

The standard for this in Python is OpenTelemetry. It defines traces, spans, and context so your data works with many backends, not just one.

Start a Span

You wrap work in a span using a context manager. Everything inside it is timed and nested under the current trace automatically.

from opentelemetry import trace
tracer = trace.get_tracer("mcp")

with tracer.start_as_current_span("search_tool"):
    run_search()

Add Attributes

Decorate a span with attributes: small key-value facts like the tool name or result count. They make a trace far easier to read later.

span = trace.get_current_span()
span.set_attribute("tool.name", "search")
span.set_attribute("result.count", 3)

Spans Catch Errors

When a step fails, mark its span with the error status. The trace then shows you exactly which hop broke the request, not just that it broke.

Context Propagation

To trace across a network call, you pass the trace context along in headers. This propagation keeps the remote step under the same trace.

Link Logs to Traces

Put the trace ID into your structured logs too. Now a log line and its full trace point at each other, and debugging gets dramatically faster.

Exporting Traces

Spans are sent to a backend through an exporter, often via the OTLP protocol. The backend then draws the timeline you click through.

Quick Check

Let us confirm the trace structure.

Recap

You can now trace a call end to end with spans under one trace ID, enriched with attributes, error status, and logs that link straight back. 🗺️

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

هل درس «تتبّع استدعاء أداة من البداية إلى النهاية» مجاني؟

نعم — نص درس «تتبّع استدعاء أداة من البداية إلى النهاية» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة MCP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MCP Academy 4 دروس في المجموع.

ماذا ستتعلم في «تتبّع استدعاء أداة من البداية إلى النهاية»؟

تابعوا طلبًا واحدًا عبر كامل المكدس. تتمرن على MCP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ MCP Academy؟

لا تُشترط خبرة سابقة. MCP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «تتبّع استدعاء أداة من البداية إلى النهاية»؟

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

هل يمكنني كتابة وتشغيل أكواد في درس MCP Academy هذا؟

نعم. كل درس في MCP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

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

  1. ما ينبغي قياسه في الخادم
  2. سجلات منظمة قابلة للبحث
  3. تتبّع استدعاء أداة من البداية إلى النهاية
  4. التنبيه عند الأعطال وإساءة الاستخدام
← العودة إلى MCP Academy