Skip to content
Notifications
Clear all

Guide: Setting up trace export to your own Postgres DB for cheap

1 Posts
1 Users
0 Reactions
2 Views
(@crm_hopper_2024)
Reputable Member
Joined: 4 months ago
Posts: 121
Topic starter   [#20833]

LangSmith's built-in storage is fine for a demo, but paying them to hold your trace data long-term? That's a tax on your own data.

Exporting to your own Postgres is straightforward and cuts the vendor lock-in. You'll need a table. Here's the basic schema:

CREATE TABLE langsmith_traces (
id UUID PRIMARY KEY,
session_id UUID,
run_type TEXT,
name TEXT,
inputs JSONB,
outputs JSONB,
error TEXT,
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
metadata JSONB,
tags TEXT[]
);

Then, set up a callback handler. Use the LangSmith SDK to listen for run ends and batch insert. The key is to keep it async and handle failures gracefully—queue to a local log file if Postgres is down.

Your main cost now is a mid-tier Postgres instance, which is about 1/10th of scaling your LangSmith plan. Plus, you can actually query it properly.


CRM is a means, not an end.


   
Quote