WeKnora/internal
shenk-b 5ee96019e0 feat(tracing): migrate langfuse client to OTLP/OTel wire protocol
Migrate WeKnora's Langfuse tracing from the legacy /api/public/ingestion
batch API to the OpenTelemetry Go SDK emitting OTLP/HTTP to
/api/public/otel/v1/traces — the Langfuse v3+ standard ingestion protocol.

Why: Langfuse v3 deprecated the legacy ingestion API in favor of OTLP, and
OTel-only backends (e.g. the LiteFuse Doris fork) dropped it entirely, so the
legacy client was incompatible. Migrating to the OTel SDK also adds W3C
traceparent cross-service propagation: an upstream caller's trace id is
inherited so its run and the WeKnora call land under one trace in the UI.

What:
- Manager owns an OTel TracerProvider backed by an otlptracehttp exporter
  (Basic auth + the x-langfuse-ingestion-version gate header). Spans are
  buffered by BatchSpanProcessor and exported complete on End, so a long
  trace no longer fragments across flush batches.
- *Trace/*Span/*Generation wrap OTel spans; the public API (StartTrace/
  Span/Generation, handles, InjectTracing, asynq/gin middleware, Config,
  TokenUsage) is unchanged, so callers (agent/chat/handler/scheduler/asynqdl)
  need no edits.
- W3C traceparent: GinMiddleware extracts traceparent from incoming requests;
  AsynqMiddleware + InjectTracing propagate it across the asynq payload.
  types.TracingContext gains a LangfuseTraceparent field.
- logger.CloneContext preserves the active OTel span across context rebuilds
  so child spans (agent engine, summary generation) stitch to the HTTP trace
  instead of orphaning into separate traces.
- StartSpan/StartGeneration re-establish the parent from the *Trace handle
  when the ctx lost the active OTel span, covering background/derived contexts.

Compatibility: works with Langfuse v3+ (cloud / self-hosted / the bundled
docker-compose profile) and LiteFuse. Drops Langfuse v2 (legacy-only) support.
Uses the OTel Go SDK already (indirectly) in go.mod, promoting
otlptracehttp to direct; no third-party langfuse-go library.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 16:30:45 +08:00
..
agent feat(agent): enhance suggested questions API with tag scopes 2026-07-17 10:19:43 +08:00
application fix(chat): emit retrieval references when citation output is disabled 2026-07-17 11:38:35 +08:00
assets feat(assets): add ASR test audio file and embed it in the application 2026-04-02 21:27:27 +08:00
common fix(redis): harden TLS tests and surface TLS config at startup 2026-07-06 23:04:52 +08:00
config refactor(terminology): rename user-facing tenant labels to workspace 2026-07-14 16:14:43 +08:00
container feat(im,datasource): support Lark, Feishu's international edition 2026-07-17 11:05:54 +08:00
database feat(system-info): surface DB migration errors with troubleshooting links 2026-05-14 16:34:50 +08:00
datasource feat(im,datasource): support Lark, Feishu's international edition 2026-07-17 11:05:54 +08:00
errors refactor(terminology): rename user-facing tenant labels to workspace 2026-07-14 16:14:43 +08:00
event feat(mcp): prompt and resume OAuth authorization mid-conversation 2026-06-29 23:22:28 +08:00
handler feat(im,datasource): support Lark, Feishu's international edition 2026-07-17 11:05:54 +08:00
im feat(im,datasource): support Lark, Feishu's international edition 2026-07-17 11:05:54 +08:00
infrastructure fix(web-search): polish Keenable provider integration after #1946 2026-07-07 17:14:39 +08:00
llmreference feat(agent): add per-agent citation output toggle 2026-07-17 10:19:43 +08:00
llmresource fix(tests): update resource alias syntax from 'res:' to 'res://' in tests and registry 2026-07-15 17:02:43 +08:00
logger feat(tracing): migrate langfuse client to OTLP/OTel wire protocol 2026-07-17 16:30:45 +08:00
mcp feat(im): include per-service MCP OAuth URLs in IM auth notices 2026-07-01 17:53:54 +08:00
middleware refactor(terminology): rename user-facing tenant labels to workspace 2026-07-14 16:14:43 +08:00
models feat(resource): add stable resource registry with LLM-context alias compaction 2026-07-15 17:02:43 +08:00
ratelimit feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
router feat(chat): add session-scoped temporary attachments with async parsing 2026-07-16 17:41:27 +08:00
runtime fix(redis): harden TLS tests and surface TLS config at startup 2026-07-06 23:04:52 +08:00
sandbox perf(sandbox): compile command-substitution regexps once 2026-06-16 19:51:32 +08:00
searchutil fix(chat): use Markdown for LLM image context and normalize legacy XML 2026-07-15 18:10:31 +08:00
storageallowlist fix(storage): align default provider fallback with STORAGE_ALLOW_LIST 2026-07-15 11:05:00 +08:00
stream feat(redis): support TLS for Redis connections (#1930) 2026-07-06 23:02:02 +08:00
tracing/langfuse feat(tracing): migrate langfuse client to OTLP/OTel wire protocol 2026-07-17 16:30:45 +08:00
types feat(tracing): migrate langfuse client to OTLP/OTel wire protocol 2026-07-17 16:30:45 +08:00
utils feat(resource): add stable resource registry with LLM-context alias compaction 2026-07-15 17:02:43 +08:00