feat: add langfuse plugin for LLM observability#13095
feat: add langfuse plugin for LLM observability#13095sihyeonn wants to merge 3 commits intoapache:masterfrom
Conversation
|
This PR contains three fundamentally different features:
Apache APISIX community practice requires each PR to focus on a single feature. These three features have different review dimensions, testing requirements, and regression risks; please separate them into independent PRs. |
|
Hi @sihyeonn, following up on the previous review comments. Please let us know if you have any updates. Thank you. |
187a719 to
d3003c0
Compare
|
Hi @sihyeonn, my suggestion is to only keep the feature-related code in the current PR, and submit other changes in separate PRs. |
Add a new langfuse plugin that sends AI request traces to Langfuse via its ingestion API using batch-processor-manager pattern. Features: - Auto-detect AI endpoints (configurable patterns) - Generate trace-create and generation-create batch items per request - W3C traceparent header parsing and propagation - Token usage extraction (ai-proxy ctx > nginx vars > response body) - Support for X-Langfuse-Tags and X-Langfuse-Metadata headers - Basic auth with encrypt_fields for secret key protection - Connection keepalive for Langfuse API calls Signed-off-by: Sihyeon Jang <sihyeon.jang@navercorp.com>
Move langfuse_host, langfuse_public_key, langfuse_secret_key, ssl_verify, timeout, detect_ai_requests, and ai_endpoints from per-route schema to metadata_schema (plugin_attr), following the opentelemetry plugin pattern. Per-route schema now only contains include_metadata. Remove encrypt_fields (custom feature, not in OSS). Signed-off-by: Sihyeon Jang <sihyeon.jang@navercorp.com>
Remove /v1-prefixed entries since has_suffix matching already covers them via shorter suffixes (e.g. /chat/completions matches both /chat/completions and /v1/chat/completions). Signed-off-by: Sihyeon Jang <sihyeon.jang@navercorp.com>
d3003c0 to
9c4b25a
Compare
Description
Add a new
langfuseplugin that sends LLM request traces to Langfuse for AI observability. The plugin uses the batch-processor-manager pattern (same as http-logger) to send trace data via Langfuse's ingestion API.Key features:
trace-createandgeneration-createbatch items per requesttraceparentheader parsing and propagation for distributed tracingctx.ai_token_usage(ai-proxy) > nginx vars > response body parsingX-Langfuse-TagsandX-Langfuse-Metadatacustom headersencrypt_fieldsfor secret key protection in etcdWhich issue(s) this PR fixes:
Fixes #
Checklist