🪢 Langfuse 图解教程Langfuse Visual Guide 第二部分 · 前置基础Part 2 · Foundations 06 / 55
第二部分 · 前置基础Part 2 · Foundations

给 LLM 应用埋点Instrumenting an LLM app

🧭 读前Before you start
先读 第3课 理解三大支柱,本课讲如何用 SDK 把它们埋进真实应用。
Read Lesson 3 on the three pillars; this lesson shows how to instrument them into a real app via the SDK.

第 5 课的全链路里,第一段是「SDK 创建事件」。这一课就把镜头对准这第一段:在数据还没离开你的应用之前,它是怎么被「埋点」生成的。 你会看到 Langfuse 接收数据的两个入口——一种是用 Langfuse 自家的 SDK 发「原生事件」,另一种是走业界标准的 OpenTelemetry(OTLP)。理解了「应用这头发出的是什么」,后面第三部分「服务端怎么收、怎么处理」才有的放矢。

🔌 生活类比
埋点就像给一栋大楼装传感器:你不改变大楼本身的功能,只是在关键位置(大门、电梯、机房)装上记录器,把「谁什么时候经过、停留多久」记下来。 Langfuse 的 SDK 是它自家定制的传感器,装起来最贴合、信息最全;而 OpenTelemetry 像一套通用接口的传感器标准—— 你楼里要是已经按这套标准装了线,Langfuse 直接接上现成的线就能收数据,不用重装。两条路,殊途同归:都是把应用运行的「踪迹」送出来。 这一课的目标,就是让你看清「传感器这头到底发出了什么」——只有先看懂应用发出的原料,才能理解后面服务端是怎么把它加工成 trace 树和宽事件表的。
两条入口,殊途同归 你的 LLM 应用埋点发生在这里 Langfuse SDK原生事件 trace/observation/score OpenTelemetryOTLP 标准 span → 映射成 observation 公共摄取 APIweb · 收下入队 SDK 路:ingestion.ts · OTel 路:otel/v1/traces(最终都进同一条摄取链路)
两个入口:用 Langfuse SDK 发原生事件(web/src/pages/api/public/ingestion.ts),或用 OpenTelemetry OTLP 发标准 span(web/src/pages/api/public/otel/v1/traces,span 会被映射成 observation)。两条路最后汇入同一条服务端摄取链路(第三部分)。
几行 SDK 代码 → 一个事件信封 from langfuse import observe @observe(as_type="generation") def answer(q): resp = llm(q) langfuse.update_current_ generation(model="gpt-4o", input=q, output=resp, usage_details={…}) # 仅埋点,业务逻辑不变 生成 { // 事件信封 "id": "evt_9f", "type": "generation-create", "timestamp": "2025-…Z", "body": { "traceId": "chat_a1b2", "name": "answer", "model": "gpt-4o", "input": {…}, "output": "…" } } → HTTP 批量发往 /ingestion
埋点 = 把调用翻译成事件(事件类型 generation-create 等对齐摄取 API;值为示例):你只在业务代码旁加几行 @observe/update_current_generation,SDK 就把这次调用打包成一个事件信封({id, type, timestamp, body}),攒批后发往服务端——下游所有存储与查询都从这个信封开始。

事件信封:你的应用发出的是什么

无论走哪条入口,应用发出的本质都是一批事件(event)。Langfuse 定义了一组事件类型(packages/shared/src/server/ingestion/types.ts 的 eventTypes), 每个事件描述「对哪个对象做了什么」:

事件类型含义
TRACE_CREATE创建/更新一个 trace(整次交互的外壳)
SPAN_CREATE / SPAN_UPDATE开始 / 结束一个 span 型 observation(有耗时的一段)
GENERATION_CREATE记录一次 LLM 调用(generation 型 observation)
OBSERVATION_CREATE / OBSERVATION_UPDATE通用的 observation 创建 / 更新
EVENT_CREATE记录一个瞬时事件
SCORE_CREATE提交一个 score(评分)

注意这里有 CREATE 也有 UPDATE——这正是第 5 课「合并」的来源:一个 span 通常先 SPAN_CREATE(开始时),结束时再 SPAN_UPDATE(补上耗时、输出)。 应用把这些事件攒成一批,一次 HTTP 请求发给摄取 API,服务端再去合并。所以你在 SDK 里写的 langfuse.trace(...)、span.end(), 本质上就是在生成这些事件。

SDK 调用 → 事件 → 攒批 → 一次 POST langfuse.trace() .generation() gen.end() TRACE_CREATE GENERATION_CREATE OBSERVATION_UPDATE 攒成一批 events[] 1 次 POST → 摄取 API CREATE 与 UPDATE 并存 → 正是第 5 课「合并」的来源

概念上,你在应用里写的埋点代码大致长这样(不同语言 SDK 形态略有差异,这里只示意「调用 → 事件」的对应关系;图中 langfuse.trace()/.generation() 是显式写法,现代 Python SDK 多用 @observe 装饰器,底层产生同样的 CREATE/UPDATE 事件):

# 创建一个 trace(发出 TRACE_CREATE)
trace = langfuse.trace(name="chat", user_id="u_42")

# 在 trace 下记录一次 LLM 调用(发出 GENERATION_CREATE)
gen = trace.generation(name="answer", model="gpt-4o", input=prompt)
result = call_llm(prompt)
# 调用结束,补上输出与用量(发出 OBSERVATION_UPDATE)
gen.end(output=result, usage={"input": 800, "output": 440})

# 给这次回答打个分(发出 SCORE_CREATE)
trace.score(name="helpfulness", value=0.9)

关键观察:你只是在原有业务代码旁边「顺手记一笔」,并没有改变 call_llm 本身的逻辑。好的埋点应当尽量不侵入—— 它不该决定你的应用怎么跑,只是旁观并记录。这也呼应了第 1 课的定位:Langfuse 站在你应用旁边,而不是里面。 正因为埋点是「旁路」的,它出问题(比如网络抖动发不出去)也不应拖垮你的主流程——SDK 通常会异步、批量、失败可丢地发送,把对应用的影响压到最低。把交互拆成「一串带类型的小事件」而不是「一个大对象」,正是为了让它们能分批、增量、乱序地发送。

那「一串带类型的小事件」到底长什么样?源码里每个事件都是同一个信封:一个 base(id + timestamp + metadata),再 extend 出 type(取值来自 eventTypes 映射)和 body(这种类型特有的字段)。一次 LLM 调用,SDK 可能发 generation-create 起头、generation-update 收尾——同一个信封、不同的 type,分批送达,worker 再按 id 合并(第 5 课已预演过)。

packages/shared/src/server/ingestion/types.ts:259,597事件信封 + 事件类型
// 每个上报事件都是「同一个信封」:base + type + body
const base = z.object({
  id: idSchema,                              // 这条事件的唯一 id
  timestamp: z.iso.datetime({ offset: true }),  // 何时发生(合并冲突以更晚者为准)
  metadata: jsonSchema.nullish(),
});
const generationCreateEvent = base.extend({
  type: z.literal(eventTypes.GENERATION_CREATE),  // 信封上的「类型」标签
  body: CreateGenerationBody,                // 这种类型特有的字段
});

// type 的合法取值(节选)——一次交互拆成这些小事件
export const eventTypes = {
  TRACE_CREATE: "trace-create",        SCORE_CREATE: "score-create",
  GENERATION_CREATE: "generation-create", GENERATION_UPDATE: "generation-update",
  SPAN_CREATE: "span-create",  EVENT_CREATE: "event-create",  …
} as const;

两种入口:原生 SDK vs OpenTelemetry

为什么要同时支持两条入口?因为它们服务两类用户:

🎯 Langfuse SDK(原生)

Langfuse 官方的 Python/JS SDK,直接发上面那套原生事件。信息最全、最贴合(prompt 关联、用量、成本字段都能精确上报),是大多数人的首选。入口:ingestion.ts。

🔌 OpenTelemetry(OTLP)

如果你的系统已经用 OTel 做可观测,不想再引一套 SDK,就可以把 OTel 的 span 直接发到 Langfuse 的 OTLP 端点(otel/v1/traces)。Langfuse 把标准 span 映射成 observation。代价是有些 Langfuse 专有语义要靠约定俗成的属性名传递。

这是一个典型的「拥抱标准 vs 发挥专长」的权衡。OTel 是云原生可观测的事实标准,支持它意味着 Langfuse 能无缝接入已有的 OTel 生态—— 你不必为了用 Langfuse 就把埋点全部重写。但 OTel 的通用模型并不天然懂「prompt 版本」「token 用量」这些 LLM 专有概念,所以原生 SDK 在表达力上仍更强。 Langfuse 的选择是两者都要:用 OTLP 降低接入门槛,用原生 SDK 提供最佳体验。OTel 这条路的服务端处理,单独放在第 18 课讲。

create 然后 update:事件是「增量」的

再强调一遍这个对理解整条链路至关重要的点:一个 observation 的信息往往不是一次发齐的。看一次 LLM 调用的典型时间线:

t0 开始GENERATION_CREATEmodel=gpt-4o, input=…(这时还没有输出)
t1 结束OBSERVATION_UPDATEoutput=…, usage=1240 tok, latency=1.8s
服务端worker 把 create + update 合并成一条最终 observation(第 15 课)
GENERATION_CREATEmodel, input(t0 开始时发) OBSERVATION_UPDATEoutput, usage(t1 结束时发) worker 合并第 15 课 一条最终 observationmodel+input+output+usage
两个事件,一条记录:先后到达的 CREATE 与 UPDATE 被 worker 合并成同一条最终 observation。这就是为什么 SDK 那头可以「拆开发」、而你在 UI 里看到的却是完整的一条。

为什么要这样「增量」上报,而不是等全部结束再发一条完整的?因为这样应用能更早地把「开始了」这件事记下来——即使后面调用崩了、超时了, 你至少知道「它确实开始过、卡在了这一步」。如果非要等结束才发,那一旦中途挂掉,这一步就彻底消失,反而最该被观测的失败 case 被漏掉了。 增量上报 + 服务端合并,是「边发生边记录」的可观测理念在协议层的体现。

🎯 设计取舍
把「事件增量上报 + 服务端合并」这套协议,复杂度放在哪一端? 放在服务端。SDK 那头被刻意做得很「笨」——只管把发生的事拆成小事件发出去, 不负责拼装最终状态;真正麻烦的「把先后到达、可能乱序、可能重复的事件收敛成一致的一行」交给 worker(第 15 课)。这么分工的好处是:SDK 轻、对应用影响小、各语言都好实现; 而最复杂、最需要小心的合并逻辑只在一处(服务端)维护,不必每个语言的 SDK 各写一遍、各错一遍。把复杂度收敛到一个能严格测试的地方。这条「客户端薄、服务端厚」的取舍,在很多大型系统里都能见到,Langfuse 只是把它用在了遥测协议上。
🎯 本课要点
  • 埋点发生在你的应用里:把运行踪迹拆成一批事件发给 Langfuse,不改变业务逻辑。
  • 两个入口:Langfuse 原生 SDK(ingestion.ts,表达力最强)或 OpenTelemetry OTLP(otel/v1/traces,无缝接入已有 OTel)。
  • 事件类型(eventTypes):TRACE_CREATE / SPAN_CREATE / GENERATION_CREATE / OBSERVATION_UPDATE / SCORE_CREATE …,描述「对哪个对象做了什么」。
  • 事件是增量的(create 开始、update 补全),所以「边发生边记录」,失败 case 也不丢——服务端负责合并(第 15 课)。
  • 协议把复杂度放在服务端:SDK 轻、好移植;合并逻辑只在一处维护。

🧪 自测 · 想一想为什么这么设计

1. Langfuse 为什么既支持自家 SDK 的“原生事件”,又支持 OpenTelemetry(OTLP)?
  1. 因为 OTel 比原生事件携带更多 LLM 专有语义
  2. 原生 SDK 表达力最强(精确报 prompt/用量/成本),OTel 则让已经用 OTel 的系统无缝接入、无需重写埋点;两者各服务一类用户
  3. 因为原生 SDK 已经废弃,OTel 是唯一入口
  4. 为了让数据走两条完全独立的存储
看答案与解析 点击展开
答案:B。这是“拥抱标准 vs 发挥专长”的权衡:OTel 是云原生可观测的事实标准,支持它降低接入门槛;但其通用模型不天然懂 prompt 版本/token 用量,原生 SDK 更精确。Langfuse 两者都要——OTLP 降门槛,原生 SDK 给最佳体验。
2. 一个 span 型 observation 常常先发 SPAN_CREATE、结束时再发 SPAN_UPDATE。这种“增量上报”的主要好处是什么?
  1. 为了减少事件数量
  2. 能更早记下“它开始了”,即使后面崩溃/超时也知道卡在哪步——失败 case 不会因为“没等到结束”而彻底消失
  3. 为了让 SDK 自己拼装最终状态
  4. 因为 ClickHouse 只接受两次写入
看答案与解析 点击展开
答案:B。若等结束才发一条完整事件,一旦中途挂掉这一步就彻底消失,而失败恰恰最该被观测。增量上报 = “边发生边记录”,服务端再把 create+update 合并成一条(第 15 课)。
3. 这套“事件增量上报 + 合并”的协议,把最复杂的合并逻辑放在哪一端?为什么?
  1. 放在前端 UI 渲染时
  2. 放在数据库触发器里
  3. 放在 SDK:每个语言各自实现合并
  4. 放在服务端(worker):SDK 只管把小事件发出去,合并“可能乱序/重复的事件成一致一行”只在一处维护,避免每种语言 SDK 各写各错
看答案与解析 点击展开
答案:D。把复杂度收敛到一个能严格测试的地方(服务端):SDK 因此轻、好移植、对应用影响小;合并这种最易错的逻辑只在 worker 维护一份,而不是散落在每个语言 SDK 里。
💭 发散思考(没有标准答案,动手或动脑想想)
  • 如果你要给自己的应用加埋点,你会选 Langfuse 原生 SDK 还是 OpenTelemetry?你的系统现状(有没有已用 OTel、需不需要精确成本)会怎么影响这个选择?

In Lesson 5's pipeline, the first leg was "SDK creates events". This lesson focuses on that first leg: how, before data ever leaves your app, it gets instrumented into existence. You'll see Langfuse's two entry points — sending "native events" via the Langfuse SDK, or sending standard OpenTelemetry (OTLP). Understanding "what the app side emits" makes Part 3 ("how the server receives and processes it") land.

🔌 Analogy
Instrumentation is like fitting a building with sensors: you don't change the building's function, you just place recorders at key spots (door, elevator, server room) noting "who passed when, stayed how long". The Langfuse SDK is its own custom sensor — the best fit, richest signal; OpenTelemetry is like a standard sensor interface — if your building is already wired to that standard, Langfuse just plugs into the existing wiring. Two paths, same end: ship the app's "traces" out. This lesson's goal is to make clear "what the sensor end actually emits" — only by understanding the raw material the app sends can you grasp how the server later refines it into trace trees and wide-event tables.
Two entries, same destination your LLM appinstrumentation here Langfuse SDKnative events trace/observation/score OpenTelemetryOTLP span → mapped to observation public ingest APIweb · accept+enqueue SDK path: ingestion.ts · OTel path: otel/v1/traces (both join one ingestion path)
Two entries: send native events with the Langfuse SDK (web/src/pages/api/public/ingestion.ts), or standard spans via OpenTelemetry OTLP (web/src/pages/api/public/otel/v1/traces, spans mapped to observations). Both converge on the same server-side ingestion path (Part 3).
A few lines of SDK code → one event envelope from langfuse import observe @observe(as_type="generation") def answer(q): resp = llm(q) langfuse.update_current_ generation(model="gpt-4o", input=q, output=resp, usage_details={…}) # instrument only; logic unchanged emits { // event envelope "id": "evt_9f", "type": "generation-create", "timestamp": "2025-…Z", "body": { "traceId": "chat_a1b2", "name": "answer", "model": "gpt-4o", "input": {…}, "output": "…" } } → batched HTTP POST to /ingestion
Instrumenting = translating calls into events (event types like generation-create per the ingestion API; values illustrative): you add a few @observe/update_current_generation lines beside your business code, and the SDK packages the call into an event envelope ({id, type, timestamp, body}), batches it, and sends it server-side — every downstream store and query starts from this envelope.

The event envelope: what your app emits

Whichever entry, the app essentially emits a batch of events. Langfuse defines a set of event types (eventTypes in packages/shared/src/server/ingestion/types.ts), each describing "what was done to which object":

Event typeMeaning
TRACE_CREATEcreate/update a trace (the interaction's shell)
SPAN_CREATE / SPAN_UPDATEstart / end a span-type observation (a timed unit)
GENERATION_CREATErecord an LLM call (generation-type observation)
OBSERVATION_CREATE / OBSERVATION_UPDATEgeneric observation create / update
EVENT_CREATErecord an instantaneous event
SCORE_CREATEsubmit a score

Note there's both CREATE and UPDATE — this is the source of Lesson 5's "merge": a span usually starts with SPAN_CREATE and ends with SPAN_UPDATE (adding duration, output). The app batches these events into one HTTP request to the ingestion API, and the server merges them. So your langfuse.trace(...) and span.end() calls are essentially generating these events.

SDK call → event → batch → one POST langfuse.trace() .generation() gen.end() TRACE_CREATE GENERATION_CREATE OBSERVATION_UPDATE batched events[] 1 POST → ingestion API CREATE and UPDATE coexisting → exactly the source of Lesson 5's merge

Conceptually, your instrumentation code looks roughly like this (SDK shapes differ by language; this just shows the "call → event" mapping; the langfuse.trace()/.generation() calls shown are an explicit illustration — modern Python SDKs use the @observe decorator, which emits the same CREATE/UPDATE events):

# create a trace (emits TRACE_CREATE)
trace = langfuse.trace(name="chat", user_id="u_42")

# record an LLM call under the trace (emits GENERATION_CREATE)
gen = trace.generation(name="answer", model="gpt-4o", input=prompt)
result = call_llm(prompt)
# call ends; add output and usage (emits OBSERVATION_UPDATE)
gen.end(output=result, usage={"input": 800, "output": 440})

# score this answer (emits SCORE_CREATE)
trace.score(name="helpfulness", value=0.9)

Key observation: you merely "jot a note alongside" your existing business code — you didn't change call_llm's logic. Good instrumentation is as non-intrusive as possible — it shouldn't dictate how your app runs, only observe and record. This echoes Lesson 1: Langfuse sits beside your app, not inside it. Because instrumentation is "side-channel", its failure (e.g. a network hiccup) shouldn't take down your main flow — SDKs typically send asynchronously, batched, drop-on-failure, minimizing impact on the app.

So what does "a stream of typed little events" actually look like? In the source, every event is the same envelope: a base (id + timestamp + metadata), then extended with a type (a value from the eventTypes map) and a body (the fields specific to that type). One LLM call may have the SDK send a generation-create to start and a generation-update to finish — same envelope, different type, sent in batches, merged by id by the worker (rehearsed in Lesson 5).

packages/shared/src/server/ingestion/types.ts:259,597event envelope + event types
// every reported event is "the same envelope": base + type + body
const base = z.object({
  id: idSchema,                              // unique id of this event
  timestamp: z.iso.datetime({ offset: true }),  // when it happened (later wins on merge)
  metadata: jsonSchema.nullish(),
});
const generationCreateEvent = base.extend({
  type: z.literal(eventTypes.GENERATION_CREATE),  // the "type" tag on the envelope
  body: CreateGenerationBody,                // fields specific to this type
});

// the valid values of type (excerpt) — one interaction split into these little events
export const eventTypes = {
  TRACE_CREATE: "trace-create",        SCORE_CREATE: "score-create",
  GENERATION_CREATE: "generation-create", GENERATION_UPDATE: "generation-update",
  SPAN_CREATE: "span-create",  EVENT_CREATE: "event-create",  …
} as const;

Two entries: native SDK vs OpenTelemetry

Why support both? Because they serve two kinds of users:

🎯 Langfuse SDK (native)

The official Python/JS SDKs emit the native events above. Richest, best-fit signal (prompt linkage, usage, cost reported precisely), the default for most. Entry: ingestion.ts.

🔌 OpenTelemetry (OTLP)

If your system already uses OTel for observability and you'd rather not add another SDK, send OTel spans to Langfuse's OTLP endpoint (otel/v1/traces). Langfuse maps standard spans to observations. The cost: some Langfuse-specific semantics ride on convention-based attribute names.

This is a classic "embrace the standard vs play to your strengths" trade-off. OTel is the de-facto standard for cloud-native observability, so supporting it lets Langfuse plug into existing OTel ecosystems — you needn't rewrite all your instrumentation to adopt Langfuse. But OTel's generic model doesn't natively understand LLM-specific concepts like "prompt version" or "token usage", so the native SDK is still more expressive. Langfuse chooses both: OTLP lowers the barrier, the native SDK gives the best experience. The server-side handling of the OTel path is its own Lesson 18.

create then update: events are "incremental"

Once more, a point crucial to understanding the whole path: an observation's info often isn't sent all at once. Look at a typical LLM call timeline:

t0 startGENERATION_CREATEmodel=gpt-4o, input=… (no output yet)
t1 endOBSERVATION_UPDATEoutput=…, usage=1240 tok, latency=1.8s
serverworker merges create + update into one final observation (L15)
GENERATION_CREATEmodel, input (sent at t0) OBSERVATION_UPDATEoutput, usage (sent at t1) worker mergeL15 one final observationmodel+input+output+usage
Two events, one record: the CREATE and UPDATE arriving at different times are merged by the worker into one final observation. That's why the SDK can "send in pieces" while you see one complete row in the UI.

Why report "incrementally" instead of waiting and sending one complete event at the end? So the app can record "it started" earlier — even if the call later crashes or times out, you at least know "it did start and got stuck here". Wait until the end and a mid-flight crash makes that step vanish entirely, losing exactly the failure cases most worth observing. Incremental reporting + server merge is the protocol-level expression of "record as it happens" observability.

🎯 Design trade-off
Where does the "incremental events + server merge" protocol put the complexity? On the server. The SDK is deliberately "dumb" — it just splits what happens into small events and ships them, not assembling the final state; the truly tricky "converge possibly-out-of-order, possibly-duplicate events into one consistent row" goes to the worker (L15). The payoff: the SDK is light, low-impact, easy to implement in every language; and the most complex, careful merge logic lives in one place (the server), not re-implemented (and re-bugged) in each language SDK. Converge complexity to one strictly testable place. This "thin client, thick server" trade shows up in many large systems; Langfuse just applies it to a telemetry protocol.
🎯 Key points
  • Instrumentation happens in your app: split the run-time trace into a batch of events sent to Langfuse, without changing business logic.
  • Two entries: Langfuse native SDK (ingestion.ts, most expressive) or OpenTelemetry OTLP (otel/v1/traces, plugs into existing OTel).
  • Event types (eventTypes): TRACE_CREATE / SPAN_CREATE / GENERATION_CREATE / OBSERVATION_UPDATE / SCORE_CREATE …, describing "what was done to which object".
  • Events are incremental (create starts, update completes), so "record as it happens" and failures aren't lost — the server merges (L15).
  • The protocol puts complexity on the server: SDKs stay light and portable; merge logic lives in one place.

🧪 Self-test - think about the design

1. Why does Langfuse support both its own SDK 'native events' and OpenTelemetry (OTLP)?
  1. Because OTel carries more LLM-specific semantics than native events
  2. The native SDK is most expressive (precise prompt/usage/cost), while OTel lets systems already on OTel plug in without rewriting instrumentation; each serves a different user
  3. Because the native SDK is deprecated and OTel is the only entry
  4. To route data into two completely separate stores
Show answer & explanation click to expand
Answer: B. This is 'embrace the standard vs play to strengths': OTel is the de-facto cloud-native standard, so supporting it lowers the barrier; but its generic model doesn't natively grok prompt version/token usage, where the native SDK is more precise. Langfuse does both — OTLP for reach, native SDK for the best experience.
2. A span-type observation often sends SPAN_CREATE first, then SPAN_UPDATE at the end. What's the main benefit of this 'incremental reporting'?
  1. To reduce the number of events
  2. It records 'it started' earlier, so even if it later crashes/times out you know which step stalled — failure cases don't vanish just because 'the end never came'
  3. So the SDK assembles the final state itself
  4. Because ClickHouse only accepts two writes
Show answer & explanation click to expand
Answer: B. Waiting to send one complete event means a mid-flight crash erases that step — yet failures are exactly what you most want to observe. Incremental reporting = 'record as it happens', and the server merges create+update into one row (L15).
3. In this 'incremental events + merge' protocol, where does the most complex merge logic live, and why?
  1. In the frontend at render time
  2. In database triggers
  3. In the SDK: each language implements merging itself
  4. On the server (worker): SDKs just emit small events; merging 'possibly out-of-order/duplicate events into one consistent row' lives in one place, avoiding each language SDK re-implementing (and re-bugging) it
Show answer & explanation click to expand
Answer: D. Converge complexity to one strictly testable place (the server): SDKs stay light, portable and low-impact; the error-prone merge logic is maintained once in the worker rather than scattered across every language SDK.
💭 Open questions (no single right answer - just think or try)
  • If you were instrumenting your own app, would you pick the Langfuse native SDK or OpenTelemetry? How would your system's current state (already on OTel? need precise cost?) shape that choice?