अवधारणा 13 / 16 · 9 मिनट पढ़ने का समय

Observability और tracing

OpenTelemetry से हर agent run को trace करें, production में agents और deployments की निगरानी करें, और traces में संवेदनशील content की रक्षा करें।

नमस्ते, मैं एलेक्स हूँ, आपका लेख-वाचक। मैं इस लेख में आपका मार्गदर्शन कर सकता हूँ, ताकि आप मेरे साथ सुनते हुए इसे समझ सकें।

Agents को observability और tracing क्यों चाहिए

एक agent run अक्सर सिर्फ एक model call नहीं होता। user के सवाल से final जवाब तक रास्ता tools, retries, nested calls और लंबे prompts में बँट सकता है। जवाब गलत, धीमा या महँगा हो तो आपको हर step क्रम में देखना होता है—सिर्फ आखिरी text से अनुमान नहीं लगाना चाहिए।

Microsoft Foundry observability agent runs के दौरान जो हुआ उसे दर्ज करती है: input और output, tool usage, retries, latency, token use और errors। Tracing एक run की विस्तृत रिकॉर्ड है। आप traces Microsoft Foundry portal और अपने Foundry project से जुड़े Application Insights resource में देखते हैं। Concept 8 में evaluation से quality मापना आया; tracing बताती है कि run ने वैसा व्यवहार क्यों किया, इससे पहले कि आप score लगाएँ।

  • Prompt agents और hosted agents के लिए tracing generally available है।
  • Workflow agents और external agents के लिए tracing preview में है।
  • Foundry OpenTelemetry semantic conventions follow करती है, इसलिए समर्थित tools में trace का ढाँचा एक जैसा रहता है।
  • Telemetry Azure Monitor Application Insights में store होती है; data volume और आपकी retention settings के हिसाब से extra Application Insights pricing लग सकती है।

Traces, spans और attributes

Trace को एक request की agent के भीतर पूरी कहानी समझें। Span उस कहानी में एक operation है—जैसे agent कॉल करना, tool call, या model step। Spans nest हो सकते हैं, इसलिए पता चलता है कौन सा tool किस step के अंदर चला। Attribute trace या span पर जुड़ा metadata है—parameters, timing, या search के लिए custom label।

Foundry में tracing शब्द
शब्दआपके लिए मतलब
Traceएक agent run की शुरू से अंत तक क्रमबद्ध रिकॉर्ड
Spanrun में एक operation, start/end time और nested children के साथ
AttributeTrace या span पर filter और analysis के लिए key-value विवरण
Semantic conventionsGenAI spans और attributes के shared OpenTelemetry नाम, ताकि tools data एक जैसा समझें

Multi-agent setup में invoke_agent, invoke_workflow, execute_tool और plan जैसे spans आते हैं, nested काम child spans में दिखता है। Microsoft Cisco Outshift के साथ multi-agent conventions contribute करता है; ये OpenTelemetry GenAI agent spans और W3C Trace Context पर बने हैं। OpenTelemetry GenAI semantic conventions का status Development है और future releases में बदल सकते हैं।

  • Agents और tools में span attributes एक जैसे रखें ताकि query सरल रहे।
  • Quality और performance एक view में चाहिए तो evaluation run IDs को trace data से जोड़ें।
  • Telemetry में जाने से पहले prompts, tool arguments और attributes से secrets, credentials और personal data हटाएँ या mask करें।

Foundry project में tracing चालू करें

Tracing default पर बंद है। Foundry Account Owner या Foundry Owner telemetry connect न करे तो कोई trace data collect नहीं होता। जब आप project से Application Insights resource connect करते हैं, Foundry उस project के agents के traces collect करना शुरू करता है।

  • Microsoft Foundry portal में साइन इन करें और New Foundry toggle चालू करें।
  • Foundry project खोलें। बाएँ navigation में Agents चुनें, ऊपर Traces चुनें।
  • दाएँ Connect से नया Application Insights resource बनाएँ या मौजूदा connect करें।
  • Connect न दिखे तो Manage > Project details > Connected resources > Add connection > Application Insights से wizard पूरा करें।
  • Connected Application Insights पर Log Analytics Reader role दें ताकि portal में traces query हो सकें। Log Analytics tables protected हों तो Privileged Monitoring Data Reader भी दें।
  • Agent एक बार चलाएँ, Traces view खोलें, नया trace confirm करें। Ingestion में कुछ मिनट लग सकते हैं; ज़रूरत हो तो refresh करें।

शुरुआत server-side tracing से करें। Application Insights connect होने के बाद Foundry common agent और workflow scenarios के traces बिना code change के log कर सकता है। Foundry में hosted agents के traces आमतौर पर कुछ मिनट में दिखने लगते हैं।

नया collection रोकने के लिए Application Insights connection हटाएँ या disconnect करें। पहले collect हुआ data Application Insights और Log Analytics retention settings के अंतर्गत रहता है—अलग Foundry-only store नहीं।

Server-side tracing बनाम client-side tracing

कौन सा tracing path चुनें
तरीकाआपको क्या मिलता हैकब चुनें
Server-side (portal)Application Insights connect होने पर Foundry portal में prompt agents, hosted agents और workflows के traces log करता हैFoundry में चलने वाले agents की पहली step; SDK instrumentation ज़रूरी नहीं
Client-side (preview)आपके app code से OpenTelemetry spans, Application Insights या दूसरे OTLP backends में exportAgent calls के आसपास custom logic देखनी हो या agent Foundry runtime के बाहर चले
Local toolkit tracingMicrosoft Foundry Toolkit extension से Visual Studio Code में local OTLP collectionDevelopment/debugging, हर span Application Insights में भेजे बिना

Client-side tracing Microsoft docs में preview है। OpenTelemetry packages install करें, GenAI tracing opt in करें (Python में उदाहरण AZURE_EXPERIMENTAL_ENABLE_GENAI_TRACING), और project connection string या Entra ingestion से Application Insights export करें। Portal में spans को specific agent से जोड़ने के लिए responses.create में agent_reference name और id के साथ भेजें।

  • Content recording message bodies और tool arguments capture करता है; policy allow न करे तो production में बंद रखें।
  • Entra-authenticated ingestion (preview) के लिए Application Insights connect करते समय Auth type Project managed identity set करें और telemetry भेजने वाली identities पर Monitoring Metrics Publisher दें।
  • Trace context propagation client spans को server spans से जोड़ता है; compliance trace identifiers share करने मना करे तभी बंद करें।

उदाहरण: shop support agent debug करना

कल्पना करें online shop का prompt agent order सवालों का जवाब देता है और refund tool call करता है। customer पूछता है, "Was my return approved?" Agent गलत status बताता है। Foundry project में agent खोलें, Traces चुनें, उस conversation का trace खोलें।

  • Span tree ऊपर से नीचे चलें: user input span, invoke_agent, फिर refund lookup का execute_tool।
  • Tool span पर gen_ai.tool.call.arguments और gen_ai.tool.call.result की तुलना final answer span से करें।
  • Latency बढ़ी हो तो nested spans की duration bars से देखें model slow था या tool।
  • Trace Replay (preview) खोलें, Trajectories और User tabs बदलें, Playthrough से run step-by-step देखें।
  • Trace पर thumbs-down annotation (preview) या end-user feedback (preview) log करें ताकि team बाद में similar failures filter कर सके।

Runs monitor करें और improvement loop feed करें

एक trace एक failure fix करता है। Agent Monitoring Dashboard (preview) agent के Monitor tab पर production traffic summarize करता है: token usage, latency, run success rate, evaluation metrics, और configure होने पर red teaming results। Monitoring data की retention और billing Application Insights configuration follow करती है।

Traces page पर Conversation results भी देख सकते हैं: Response ID या Trace ID से search करें, Conversation ID खोलें, history, run में tokens, ordered tool steps, input/output review करें। Chat view और span hierarchy दोनों चाहिए तो trace replay के साथ यह काम आता है।

  • Traces को evaluation datasets में बदलें: Data Generation tab से Create dataset > From traces, या traces चुनकर Add to dataset।
  • Intelligent sampling (max_samples 1 से 1,000) हर low-signal trace dump करने की बजाय diverse subset चुनता है।
  • Portal में thumbs up/down annotation (preview), या app से gen_ai.evaluation.result events—end-user feedback (preview)।
  • Trace IDs evaluation runs से जोड़ें ताकि Concept 14 evaluators वही production behavior score करें जो traces में capture है।

Sensitive data, access और लागत

Traces में user prompts, model outputs, tool arguments और system instructions हो सकते हैं। Connected Application Insights पर Log Analytics Reader वाले project members यह data पढ़ सकते हैं, जिसमें customer content शामिल हो सकता है। Traces को production logs जैसा treat करें: read access सीमित रखें, broad tracing चालू करने से पहले तय करें क्या record होगा।

  • Prompts, tool arguments या span attributes में secrets, credentials या tokens store न करें।
  • Telemetry में जाने से पहले personal data redact या minimize करें।
  • Restrict access to sensitive content in traces (preview) GenAI message attributes को AppGenAIContent table में भेजता है; Protected mark कर Privileged Monitoring Data Reader से gate करें।
  • नया collection बंद करने के लिए Application Insights disconnect करें; पुराना data Application Insights retention follow करता है।

Store हुई telemetry के sampling और archive व्यवहार Application Insights और Log Analytics settings follow करते हैं—Foundry docs में कोई fixed period stated नहीं। Tracing उन regions में है जहाँ Foundry supported है। Ingestion delay देखें: client-side spans अक्सर portal में लगभग दो से पाँच मिनट बाद दिखते हैं; trace-to-dataset jobs को नए spans देखने में Application Insights को तीस से नब्बे सेकंड लग सकते हैं।

आम गलतियाँ और आगे क्या करें

  • Portal में traces नहीं: Application Insights connected confirm करें, नया agent traffic बनाएँ, कुछ मिनट wait कर refresh करें।
  • Traces खोलते समय authorization errors: Application Insights पर Log Analytics Reader; tables protected हों तो Privileged Monitoring Data Reader।
  • Client-side spans missing: GenAI tracing enabled, packages installed, connection string या Entra ingestion roles verify करें।
  • Evaluators empty conversation देखें: invoke_agent spans में GenAI conventions के अनुसार gen_ai.input.messages और gen_ai.output.messages हों।
  • बिना review production में content recording: message bodies और tool args privacy rules तोड़ सकते हैं—policy allow न करे तो development तक सीमित रखें।

अगला कदम Concept 14: यहाँ से मिले datasets और traffic patterns पर evaluation और red teaming चलाएँ। Concepts 7 और 12 के tools और prompts iterate करते समय non-production projects में tracing चालू रखें, production rollout से पहले वही connection और access model लागू करें।

हर पाठ के स्रोत इसके अंत में दिए गए हैं: Microsoft Foundry के साथ Up-Skill।