---
title: "Tracing OpenAI agents with ClickStack"
description: "OpenAI's agents SDK has built-in tracing that can be redirected from OpenAI's hosted product to a custom TracingExporter."
url: "https://swe.quest/articles/tracing-openai-agents-with-clickstack-27a1630cee998ca8"
canonical: "https://clickhouse.com/blog/tracing-openai-agents-clickstack"
source: "ClickHouse"
published: "2025-10-27"
difficulty: "medium"
kind: "How-to"
reading_minutes: 13
tags: ["observability","ai-agents","python","analytics"]
---

# Tracing OpenAI agents with ClickStack

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-10-27, 13 min read, How-to. Original: [https://clickhouse.com/blog/tracing-openai-agents-clickstack](https://clickhouse.com/blog/tracing-openai-agents-clickstack)

## Summary

OpenAI's agents SDK has built-in tracing that can be redirected from OpenAI's hosted product to a custom TracingExporter. Spans can then be written into ClickHouse and explored in HyperDX as part of ClickStack. The worked example uses a gpt-5-mini agent that queries the ClickHouse SQL Playground through the ClickHouse MCP Server. The exporter is attached via a BatchTraceProcessor, adds the missing model name to response spans, and inserts rows into a JSON-typed ClickHouse table. The traces show tool calls, failed SQL attempts and LLM responses, which helps when comparing how different models handle ambiguous instructions.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)

## Prerequisites

- Python async basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- LLM agents and tool calling ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- ClickHouse SQL basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- distributed tracing concepts ([easy posts on Observability](https://swe.quest/tags/observability.md?difficulty=easy))

## Keywords

ClickHouse, ClickStack, HyperDX, OpenAI Agents SDK, MCP, ClickHouse MCP Server

## Related posts

- [LLM observability with ClickStack, OpenTelemetry, and MCP](https://swe.quest/articles/llm-observability-with-clickstack-opentelemetry-and-mcp-0444a970ae228536.md): ClickHouse · 2025-07-15 · Medium · 13 min read · Observability, LLMs, AI agents
  LibreChat (Node.js) and the Python ClickHouse MCP server can be instrumented with OpenTelemetry and shipped to ClickStack (HyperDX UI, OTel collector, ClickHouse) to observe LLM interactions, MCP tool calls and token usage with minimal code changes.
- [Open House observability announcements: MCP server, AI Notebooks, and ClickStack Cloud](https://swe.quest/articles/open-house-observability-announcements-mcp-server-ai-notebooks-and-clickstack-027c56eb64027b0c.md): ClickHouse · 2026-05-27 · Easy · 9 min read · Observability, AI agents, Analytics & OLAP
  ClickHouse unveiled three observability updates: ClickStack Cloud, a serverless managed OpenTelemetry endpoint now in private preview; general availability of Managed ClickStack for teams that want control over ingestion and sizing; and AI Notebooks in beta, which turn incident investigations into branching, editable, shareable workspaces.
- [Announcing the Managed ClickStack MCP Server](https://swe.quest/articles/announcing-the-managed-clickstack-mcp-server-2e355443e7bc5530.md): ClickHouse · 2026-06-24 · Medium · 8 min read · Observability, AI agents, Analytics & OLAP
  ClickStack's MCP server, which exposes observability-specific investigation tools for logs, metrics and traces to agents like Claude Code, Cursor and Codex, is now available in Managed ClickStack on ClickHouse Cloud with OAuth and per-service dedicated compute.
- [Trace and evaluate Cursor agents with Langfuse, powered by ClickHouse](https://swe.quest/articles/trace-and-evaluate-cursor-agents-with-langfuse-powered-by-clickhouse-b04d90713d1833e1.md): ClickHouse · 2026-10-22 · Medium · 5 min read · AI for coding, Observability, Evaluation, AI agents
  The Langfuse Observability plugin for Cursor captures each agent prompt as a \`Cursor Turn\` trace containing LLM observations, tool executions, subagents and token usage, stored in a wide ClickHouse observations table that avoids trace/observation joins for cost and latency aggregation.
- [The observability UI as we know it is dead. So what comes next?](https://swe.quest/articles/the-observability-ui-as-we-know-it-is-dead-so-what-comes-next-31b03aa568b097ab.md): ClickHouse · 2026-11-09 · Easy · 9 min read · Observability, AI agents, Sandboxing & isolation, Analytics & OLAP
  ClickHouse Observability Apps, now in private preview in ClickStack, let teams describe an observability application in natural language and have an agent generate it over live logs, traces and metrics, instead of waiting for a vendor to build every custom view.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
