Short answer: if you have one LLM-backed feature, one team, and no need for non-engineers to browse traces, a single Postgres table plus a thin wrapper covers cost and latency tracking in an afternoon. Pay for (or self-host) a dedicated tool when you need trace trees across multi-step agents, prompt versioning with review workflows, or a UI that product people actually use. The expensive mistake is not choosing wrong; it's logging nothing until the first surprise invoice.
What do you actually need to log?
Before comparing tools, write down the questions you will ask during an incident. In my experience they are always the same four: which feature spent the money, which model and prompt version was involved, how slow was it, and what exactly went in and out for the one bad response a user complained about.
That list is smaller than any vendor's feature page. Everything beyond it (evals, datasets, playground, annotation queues) is a separate purchase decision, not an observability requirement.
Takeaway: define your incident questions first, because they decide whether a table or a platform is the right size.
How far does a plain Postgres table get you?
Further than people expect. Here is the minimal schema I would start with:
CREATE TABLE llm_calls (
id bigserial PRIMARY KEY,
created_at timestamptz NOT NULL DEFAULT now(),
feature text NOT NULL, -- e.g. 'support_summary'
model text NOT NULL,
prompt_version text,
input_tokens integer,
output_tokens integer,
latency_ms integer NOT NULL,
status text NOT NULL, -- 'ok' | 'error'
error text,
request_body jsonb,
response_body jsonb
);
CREATE INDEX llm_calls_feature_created_idx
ON llm_calls (feature, created_at DESC);
And a wrapper that records every call, including failures. This example uses an OpenAI-style client, but the shape is the same for any SDK that returns token usage:
import time
import psycopg
from psycopg.types.json import Jsonb
conn = psycopg.connect("postgresql://localhost/app", autocommit=True)
def logged_chat(client, *, feature, prompt_version, **kwargs):
start = time.monotonic()
status, error, resp = "ok", None, None
try:
resp = client.chat.completions.create(**kwargs)
return resp
except Exception as exc:
status, error = "error", repr(exc)
raise
finally:
latency_ms = int((time.monotonic() - start) * 1000)
usage = getattr(resp, "usage", None)
conn.execute(
"""
INSERT INTO llm_calls
(feature, model, prompt_version, input_tokens, output_tokens,
latency_ms, status, error, request_body, response_body)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
""",
(
feature,
kwargs.get("model"),
prompt_version,
getattr(usage, "prompt_tokens", None),
getattr(usage, "completion_tokens", None),
latency_ms,
status,
error,
Jsonb(kwargs.get("messages")),
Jsonb(resp.model_dump(mode="json")) if resp else None,
),
)
The query that answers "which feature is costing us" is then plain SQL:
SELECT feature, model,
count(*) AS calls,
sum(input_tokens) AS in_tokens,
sum(output_tokens) AS out_tokens,
percentile_cont(0.95) WITHIN GROUP (ORDER BY latency_ms) AS p95_ms
FROM llm_calls
WHERE created_at > now() - interval '7 days'
GROUP BY feature, model
ORDER BY in_tokens DESC NULLS LAST;
Multiply tokens by your provider's current per-token rates in a small lookup table or in the dashboard layer; keep rates out of the log rows so a price change doesn't corrupt history.
What tripped me up: synchronous inserts in the request path. The finally block above adds a database round trip to every LLM call. LLM latency usually dwarfs it, but for streaming endpoints or high volume, push the insert onto a queue or background task. Also decide a retention window for request_body: prompts often contain user data, and a forever-retained table of raw inputs is a privacy liability you created yourself.
Takeaway: one table, one wrapper, and one GROUP BY answers cost, latency, and error-rate questions for a single-feature app.
When does a dedicated tool start paying for itself?
The table stops being enough at specific, nameable points rather than at a traffic threshold:
-
Multi-step traces. An agent that makes a retrieval call, three model calls, and two tool calls produces a tree. Reconstructing it from flat rows with a
parent_idis doable, but rendering and searching it is where you will start rebuilding a product. - Non-engineers need access. If support or product wants to read conversations and tag bad ones, a UI with permissions beats handing out database credentials.
- Prompt management. Versioning prompts, diffing them, and tying a version to quality scores is tedious to hand-roll well.
- Evaluation datasets. Turning production traces into test sets is a workflow, not a query.
Langfuse vs LangSmith vs Helicone: how do they differ?
Details below are as of late 2026 and these products ship quickly, so verify against current docs and pricing pages before committing.
| Langfuse | LangSmith | Helicone | |
|---|---|---|---|
| Integration style | SDKs / OpenTelemetry-based instrumentation | SDK; deepest with LangChain/LangGraph, usable without | Proxy (change base URL) or async logging |
| Self-hosting | Open-source core, self-hostable | Self-hosting is generally an enterprise arrangement | Open source, self-hostable |
| Strong at | Traces, prompt management, evals in one tool | Agent debugging and evals if you already use LangChain | Fast setup, request-level cost and caching views |
| Real drawback | Self-hosting means you operate its data stores | Value drops if you're not in the LangChain ecosystem | Proxy puts a new network hop in your critical path |
| Pricing model | Usage-based cloud tiers or your own infra | Seat plus trace-volume based | Request-volume based tiers |
If you want a tool that combines tracing, prompt versioning, and evals and can run on your own infrastructure, Langfuse is the one that fits that combination without forcing a framework choice. Its drawback is operational: the self-hosted version is several components, not a single binary, so you are trading a subscription for on-call time.
If your agents are already built on LangChain or LangGraph, LangSmith is the one that gives you step-level traces with the least instrumentation work. The drawback is that outside that ecosystem you do manual instrumentation and the seat-based model can sting as more people need access.
If you want visibility in minutes and your main concern is per-request cost, Helicone is the one that gets there by swapping a base URL. The drawback is architectural: a proxy sits between your app and the provider, so its availability becomes part of your own, and you should know your fallback before you ship it.
Takeaway: all three solve "see what happened"; they differ on how they hook in, who runs the infrastructure, and what breaks if they go down.
What is the real cost of buying versus building?
Vendor price is the visible line item. The hidden ones are on both sides:
| Cost | Build (Postgres) | Buy / self-host a platform |
|---|---|---|
| Up-front | Hours | Hours to days (integration) |
| Ongoing | Schema changes, retention jobs, dashboards | Subscription growth with trace volume, or infra upkeep |
| Data exposure | Stays in your database | Prompts and outputs leave your boundary unless self-hosted |
| Lock-in | None | Instrumentation code tied to an SDK |
| Failure mode | You forget to log a code path | Vendor outage or quota hit affects logging or, with proxies, requests |
One honest rule of thumb: the moment you catch yourself writing a trace viewer, stop and price a tool. Until then, the table is cheaper than the meeting about which tool to buy.
Takeaway: build the logging, buy the viewing, and revisit the line when you start hand-rolling UI.
FAQ
Do I need LLM observability for a small app?
Yes, but "observability" can be one table recording model, tokens, latency, and status per call. The minimum is knowing which feature spends your money.
Is Langfuse free?
The core is open source and you can self-host it at no license cost, but you pay in infrastructure and maintenance. The hosted cloud has usage-based tiers that change, so check the current pricing page.
Should I log full prompts and responses in production?
Only with a retention limit and a plan for user data, since prompts often contain personal information. Many teams log full bodies for a short window and keep only token and latency metadata long term.
Bottom line
Solo developers and small teams with one or two LLM features should start with the Postgres table and revisit when agents or non-engineers enter the picture. LangChain/LangGraph shops will get the most from LangSmith, teams that want open-source tracing plus prompt management should evaluate Langfuse, and anyone who needs cost visibility this afternoon can try Helicone's proxy approach. Whatever you choose, start logging tokens and latency before the first big bill rather than after.
Top comments (0)