<liclass="toctree-l2"><aclass="reference internal"href="../../concepts/llm_providers/supported_providers.html">Supported Providers & Configuration</a></li>
<spanid="arch-overview-tracing"></span><h1>Tracing<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#tracing"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h1>
<sectionid="overview">
<h2>Overview<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#overview"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#overview'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h2>
<codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header. This allows each component in the system to record its part of the request
<h2>Benefits of Using <codeclass="docutils literal notranslate"><spanclass="pre">Traceparent</span></code> Headers<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#benefits-of-using-traceparent-headers"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#benefits-of-using-traceparent-headers'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h2>
<ulclass="simple">
<li><p><strong>Standardization</strong>: The W3C Trace Context standard ensures compatibility across ecosystem tools, allowing
traces to be propagated uniformly through different layers of the system.</p></li>
<li><p><strong>Ease of Integration</strong>: OpenTelemetry’s design allows developers to easily integrate tracing with minimal
changes to their codebase, enabling quick adoption of end-to-end observability.</p></li>
<li><p><strong>Interoperability</strong>: Works seamlessly with popular tracing tools like AWS X-Ray, Datadog, Jaeger, and many others,
making it easy to visualize traces in the tools you’re already usi</p></li>
</ul>
</section>
<sectionid="how-to-initiate-a-trace">
<h2>How to Initiate A Trace<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#how-to-initiate-a-trace"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#how-to-initiate-a-trace'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h2>
<li><p><strong>Enable Tracing Configuration</strong>: Simply add the <codeclass="docutils literal notranslate"><spanclass="pre">random_sampling</span></code> in <codeclass="docutils literal notranslate"><spanclass="pre">tracing</span></code> section to 100`` flag to in the <aclass="reference internal"href="../../concepts/listeners.html#plano-overview-listeners"><spanclass="std std-ref">listener</span></a> config</p></li>
<li><p><strong>Trace Context Propagation</strong>: Plano automatically propagates the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header. When a request is received, Plano will:</p>
<li><p>Generate a new <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header if one is not present.</p></li>
<li><p>Extract the trace context from the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header if it exists.</p></li>
<li><p>Start a new span representing its processing of the request.</p></li>
<li><p>Forward the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header to downstream services.</p></li>
<li><p><strong>Sampling Policy</strong>: The 100 in <codeclass="docutils literal notranslate"><spanclass="pre">random_sampling:</span><spanclass="pre">100</span></code> means that all the requests as sampled for tracing.
<p>Plano uses the W3C Trace Context standard for trace propagation, which relies on the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header.
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">{version}</span></code>: The version of the Trace Context specification (e.g., <codeclass="docutils literal notranslate"><spanclass="pre">00</span></code>).</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">{trace-id}</span></code>: A 16-byte (32-character hexadecimal) unique identifier for the trace.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">{parent-id}</span></code>: An 8-byte (16-character hexadecimal) identifier for the parent span.</p></li>
<h3>Instrumentation<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#instrumentation"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#instrumentation'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h3>
<p>To integrate AI tracing, your application needs to follow a few simple steps. The steps
<li><p>Read the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header from incoming requests.</p></li>
<li><p>Start new spans as children of the extracted context.</p></li>
<li><p>Include the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header in outbound requests to propagate trace context.</p></li>
<li><p>Send tracing data to a collector or tracing backend to export spans</p></li>
<h4>Example with OpenTelemetry in Python<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#example-with-opentelemetry-in-python"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h4>
</span><spanid="line-21"><spanclass="nb">print</span><spanclass="p">(</span><spanclass="sa">f</span><spanclass="s2">"Payment service response: </span><spanclass="si">{</span><spanclass="n">response</span><spanclass="o">.</span><spanclass="n">content</span><spanclass="si">}</span><spanclass="s2">"</span><spanclass="p">)</span>
</span></code></pre></div>
</div>
</section>
</section>
</section>
<sectionid="integrating-with-tracing-tools">
<h2>Integrating with Tracing Tools<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#integrating-with-tracing-tools"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#integrating-with-tracing-tools'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h2>
<sectionid="aws-x-ray">
<h3>AWS X-Ray<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#aws-x-ray"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#aws-x-ray'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h3>
<li><p><strong>Deploy the Collector</strong>: Run the collector as a Docker container, Kubernetes pod, or standalone service.</p></li>
<li><p><strong>Ensure AWS Credentials</strong>: Provide AWS credentials to the collector, preferably via IAM roles.</p></li>
<li><p><strong>Verify Traces</strong>: Access the AWS X-Ray console to view your traces.</p></li>
</ol>
</section>
<sectionid="datadog">
<h3>Datadog<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#datadog"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#datadog'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h3>
</span><spanid="line-2"><spanclass="gp">$ </span><spanclass="nb">export</span><spanclass="w"></span><spanclass="nv">DD_SITE</span><spanclass="o">=</span>datadoghq.com<spanclass="w"></span><spanclass="c1"># Or datadoghq.eu</span>
</span></code></pre></div>
</div>
</li>
<li><p><strong>Deploy the Collector</strong>: Run the collector in your environment.</p></li>
<li><p><strong>Verify Traces</strong>: Access the Datadog APM dashboard to view your traces.</p></li>
<h3>Langtrace<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#langtrace"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#langtrace'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h3>
<p>Langtrace is an observability tool designed specifically for large language models (LLMs). It helps you capture, analyze, and understand how LLMs are used in your applications including those built using Plano.</p>
<li><p><strong>Configure Plano</strong>: Make sure Plano is installed and setup correctly. For more information, refer to the <aclass="reference external"href="https://github.com/katanemo/archgw?tab=readme-ov-file#prerequisites"rel="nofollow noopener">installation guide<svgfill="currentColor"height="1em"stroke="none"viewbox="0 96 960 960"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M188 868q-11-11-11-28t11-28l436-436H400q-17 0-28.5-11.5T360 336q0-17 11.5-28.5T400 296h320q17 0 28.5 11.5T760 336v320q0 17-11.5 28.5T720 696q-17 0-28.5-11.5T680 656V432L244 868q-11 11-28 11t-28-11Z"></path></svg></a>.</p></li>
</span><spanid="line-2"><spanclass="kn">from</span><spanclass="w"></span><spanclass="nn">langtrace_python_sdk</span><spanclass="w"></span><spanclass="kn">import</span><spanclass="n">langtrace</span><spanclass="c1"># Must precede any llm module imports</span>
</span><spanid="line-12"><spanclass="p">{</span><spanclass="s2">"role"</span><spanclass="p">:</span><spanclass="s2">"system"</span><spanclass="p">,</span><spanclass="s2">"content"</span><spanclass="p">:</span><spanclass="s2">"You are a helpful assistant"</span><spanclass="p">},</span>
<h2>Best Practices<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#best-practices"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#best-practices'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h2>
<ulclass="simple">
<li><p><strong>Consistent Instrumentation</strong>: Ensure all services propagate the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header.</p></li>
<li><p><strong>Secure Configuration</strong>: Protect sensitive data and secure communication between services.</p></li>
<li><p><strong>Performance Monitoring</strong>: Be mindful of the performance impact and adjust sampling rates accordingly.</p></li>
<li><p><strong>Error Handling</strong>: Implement proper error handling to prevent tracing issues from affecting your application.</p></li>
</ul>
</section>
<sectionid="summary">
<h2>Summary<a@click.prevent="window.navigator.clipboard.writeText($el.href); $el.setAttribute('data-tooltip', 'Copied!'); setTimeout(() => $el.setAttribute('data-tooltip', 'Copy link to this element'), 2000)"aria-label="Copy link to this element"class="headerlink"data-tooltip="Copy link to this element"href="#summary"x-intersect.margin.0%.0%.-70%.0%="activeSection ='#summary'"><svgheight="1em"viewbox="0 0 24 24"width="1em"xmlns="http://www.w3.org/2000/svg"><pathd="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></a></h2>
<p>By leveraging the <codeclass="docutils literal notranslate"><spanclass="pre">traceparent</span></code> header for trace context propagation, Plano enables developers to implement
<p>Replace placeholders such as <codeclass="docutils literal notranslate"><spanclass="pre"><Your-Aws-Region></span></code> and <codeclass="docutils literal notranslate"><spanclass="pre"><Your-Datadog-Api-Key></span></code> with your actual configurations.</p>
<li><a:data-current="activeSection === '#benefits-of-using-traceparent-headers'"class="reference internal"href="#benefits-of-using-traceparent-headers">Benefits of Using <codeclass="docutils literal notranslate"><spanclass="pre">Traceparent</span></code> Headers</a></li>
<li><a:data-current="activeSection === '#how-to-initiate-a-trace'"class="reference internal"href="#how-to-initiate-a-trace">How to Initiate A Trace</a></li>
<li><a:data-current="activeSection === '#example-with-opentelemetry-in-python'"class="reference internal"href="#example-with-opentelemetry-in-python">Example with OpenTelemetry in Python</a></li>
</ul>
</li>
</ul>
</li>
<li><a:data-current="activeSection === '#integrating-with-tracing-tools'"class="reference internal"href="#integrating-with-tracing-tools">Integrating with Tracing Tools</a><ul>