Files
openobserve/web/src
Ashish Kolhe f62d0d60c5 feat: traces for agent (#8800)
### **PR Type**
Enhancement, Bug fix


___

### **Description**
- Add distributed tracing for AI chat

- Parse W3C traceparent, fallback to UUID v7

- Enable conditional tracer provider/init

- Improve AI error logs with trace context


___

### Diagram Walkthrough


```mermaid
flowchart LR
  FE["Frontend generateTraceContext()"] -- "traceparent header" --> API["/api/{org_id}/ai/chat(_stream)"]
  API -- "Span root if enabled" --> Tracer["Tracer provider"]
  API -- "trace_id propagated" --> AIService["ai::service::{chat,chat_stream}"]
  Tracer -- "OTLP exporters" --> OO["OpenObserve OTLP"]
  Tracer -- "Filtered ai.* spans" --> OO["OpenObserve OTLP"]
  Tracer -- "Optional eval exporter" --> Eval["AI Evaluation OTLP"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>chat.rs</strong><dd><code>Add tracing headers parsing
and span creation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

src/handler/http/request/ai/chat.rs

<ul><li>Accept headers and org path in chat<br> <li> Create root tracing
spans when enabled<br> <li> Parse W3C traceparent to derive trace_id<br>
<li> Propagate trace_id to AI services and logs</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8800/files#diff-12a78cbb31b313cb3a0ca50f25c177470cf49b02708f179fe138ed3d66a2926b">+77/-12</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>main.rs</strong><dd><code>Conditional tracing setup and
AI exporters</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

src/main.rs

<ul><li>Initialize tracer when AI tracing enabled<br> <li> Add
FilteringSpanProcessor for ai.* spans<br> <li> Configure additional OTLP
exporters<br> <li> Use UUID v7 ID generator when available</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8800/files#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fc">+223/-17</a></td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>useAiChat.ts</strong><dd><code>Add traceparent to AI
chat requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/src/composables/useAiChat.ts

<ul><li>Generate and send traceparent header<br> <li> Pass abort signal
in fetch options</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8800/files#diff-830ee4f21bdbbd0fa5c5c0f43b0a1d0200831e07ccddc91982cf0371c801b046">+6/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>ai_chat.ts</strong><dd><code>Propagate traceparent in
service requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

web/src/services/ai_chat.ts

<ul><li>Include traceparent header in chat_stream<br> <li> Utilize
generateTraceContext utility</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8800/files#diff-d5a69d2b2a2a97e0875282b079de6092a5aa1e9cb93a4eb7ff68034b43eac3a1">+3/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Miscellaneous</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>wal.rs</strong><dd><code>Remove tracing attribute from
WAL list</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

src/service/search/datafusion/storage/wal.rs

- Remove unused tracing instrument on list


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8800/files#diff-9ca700516d742bbc3c93f2271b27034650124c06a594f5b668144c51d7e28637">+0/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>vite.config.ts</strong><dd><code>Adjust Vite dependency
optimization settings</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

web/vite.config.ts

<ul><li>Exclude echarts modules from optimizeDeps<br> <li> Disable
forced dependency optimization</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8800/files#diff-9430906049744cbbfe5d0b382b2466843a42cfebf755ff86fec850b0712258ef">+8/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___
2025-10-14 17:35:17 +05:30
..
2025-10-06 15:49:30 +05:30
2025-07-10 11:23:41 -07:00
2025-10-07 08:52:41 +05:30
2025-09-04 12:38:01 +05:30
2025-10-14 17:35:17 +05:30
2025-08-23 12:26:28 +05:30
2025-10-13 17:13:07 +05:30