feat: tune langfuse fanout batching

This commit is contained in:
Ravi Kumar L 2026-06-21 23:54:06 +02:00
parent 5e1c70eb58
commit 182c4a6636
10 changed files with 41 additions and 14 deletions

View file

@ -148,6 +148,8 @@ NODE_MAX_OLD_SPACE_SIZE=6144
# LANGFUSE_FANOUT_TENANT_HIPAA_BASE_URL=https://hipaa.cloud.langfuse.com
# LANGFUSE_FANOUT_MEMORY_LIMIT_MIB=256
# LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB=64
# LANGFUSE_FANOUT_BATCH_TIMEOUT=1s
# LANGFUSE_FANOUT_BATCH_SEND_SIZE=128
# LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT=1000
#=======================#

View file

@ -26,6 +26,8 @@ services:
- LANGFUSE_FANOUT_TENANT_HIPAA_BASE_URL=${LANGFUSE_FANOUT_TENANT_HIPAA_BASE_URL:-https://hipaa.cloud.langfuse.com}
- LANGFUSE_FANOUT_MEMORY_LIMIT_MIB=${LANGFUSE_FANOUT_MEMORY_LIMIT_MIB:-256}
- LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB=${LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB:-64}
- LANGFUSE_FANOUT_BATCH_TIMEOUT=${LANGFUSE_FANOUT_BATCH_TIMEOUT:-1s}
- LANGFUSE_FANOUT_BATCH_SEND_SIZE=${LANGFUSE_FANOUT_BATCH_SEND_SIZE:-128}
- LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT=${LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT:-1000}
expose:
- '4318'

View file

@ -26,6 +26,8 @@ services:
- LANGFUSE_FANOUT_TENANT_HIPAA_BASE_URL=${LANGFUSE_FANOUT_TENANT_HIPAA_BASE_URL:-https://hipaa.cloud.langfuse.com}
- LANGFUSE_FANOUT_MEMORY_LIMIT_MIB=${LANGFUSE_FANOUT_MEMORY_LIMIT_MIB:-256}
- LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB=${LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB:-64}
- LANGFUSE_FANOUT_BATCH_TIMEOUT=${LANGFUSE_FANOUT_BATCH_TIMEOUT:-1s}
- LANGFUSE_FANOUT_BATCH_SEND_SIZE=${LANGFUSE_FANOUT_BATCH_SEND_SIZE:-128}
- LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT=${LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT:-1000}
expose:
- '4318'

View file

@ -72,6 +72,8 @@ if tenant keys and a known destination are configured.
Langfuse tenant base URLs are selected from the startup-configured destination
map rendered into LibreChat and the collector. Tenant API keys can still be added
through tenant app configuration at runtime without restarting either component.
Collector batching can be tuned with `langfuseFanout.batchTimeout` and
`langfuseFanout.batchSendSize`; defaults are `1s` and `128`.
See [`otel/langfuse-fanout/README.md`](../../otel/langfuse-fanout/README.md)
for the central Langfuse secret and values example.

View file

@ -49,12 +49,12 @@ data:
- key: librechat.langfuse.destination
action: delete
batch/central:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
{{- range $name, $_destination := .Values.langfuseFanout.tenant.destinations }}
batch/by_auth_{{ $name }}:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
metadata_keys: [authorization]
metadata_cardinality_limit: ${env:LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT}
{{- end }}

View file

@ -48,6 +48,10 @@ spec:
value: {{ .Values.langfuseFanout.memoryLimitMiB | quote }}
- name: LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB
value: {{ .Values.langfuseFanout.memorySpikeLimitMiB | quote }}
- name: LANGFUSE_FANOUT_BATCH_TIMEOUT
value: {{ .Values.langfuseFanout.batchTimeout | quote }}
- name: LANGFUSE_FANOUT_BATCH_SEND_SIZE
value: {{ .Values.langfuseFanout.batchSendSize | quote }}
- name: LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT
value: {{ .Values.langfuseFanout.metadataCardinalityLimit | quote }}
volumeMounts:

View file

@ -142,6 +142,8 @@ function summarize(config) {
return [
destination,
{
timeout: batch?.timeout,
sendBatchSize: batch?.send_batch_size,
metadataKeys: sorted(batch?.metadata_keys),
metadataCardinalityLimit: batch?.metadata_cardinality_limit,
},
@ -158,6 +160,10 @@ function summarize(config) {
tenantExportFilter: processors['filter/tenant_export']?.traces?.span ?? [],
dropRoutingAttributes: processors['attributes/drop_librechat_routing']?.actions ?? [],
centralExporter: exporters['otlphttp/central'] ?? {},
centralBatch: {
timeout: processors['batch/central']?.timeout,
sendBatchSize: processors['batch/central']?.send_batch_size,
},
centralPipeline: pipelines['traces/central'] ?? {},
tenantRouterPipeline: pipelines['traces/tenant'] ?? {},
tenantExporters,

View file

@ -311,6 +311,8 @@ langfuseFanout:
baseUrl: https://hipaa.cloud.langfuse.com
memoryLimitMiB: 256
memorySpikeLimitMiB: 64
batchTimeout: 1s
batchSendSize: 128
metadataCardinalityLimit: 1000
resources: {}
podAnnotations: {}

View file

@ -68,6 +68,8 @@ LANGFUSE_FANOUT_TENANT_US_BASE_URL=https://us.cloud.langfuse.com
LANGFUSE_FANOUT_TENANT_JP_BASE_URL=https://jp.cloud.langfuse.com
LANGFUSE_FANOUT_TENANT_HIPAA_BASE_URL=https://hipaa.cloud.langfuse.com
LANGFUSE_FANOUT_TENANT_EXPORT_DISABLED=false
LANGFUSE_FANOUT_BATCH_TIMEOUT=1s
LANGFUSE_FANOUT_BATCH_SEND_SIZE=128
```
Langfuse Cloud base URL options:
@ -123,6 +125,8 @@ langfuseFanout:
baseUrl: https://jp.cloud.langfuse.com
hipaa:
baseUrl: https://hipaa.cloud.langfuse.com
batchTimeout: 1s
batchSendSize: 128
```
The chart renders the collector Deployment, Service, and collector ConfigMap,
@ -139,5 +143,8 @@ the LibreChat app ConfigMap when they are not already supplied in
override `langfuseFanout.tenant.destinations` in Helm for self-hosted or
custom destinations. Compose's included collector config is static; if you add
custom destination keys there, update or regenerate `otelcol.yaml` as well.
- `LANGFUSE_FANOUT_BATCH_TIMEOUT` and `LANGFUSE_FANOUT_BATCH_SEND_SIZE` tune
the OTel batch processors. The defaults (`1s`, `128`) favor low latency and
modest memory use; high-volume deployments may increase them for throughput.
- `LANGFUSE_FANOUT_COLLECTOR_URL` is the local collector URL used by LibreChat,
not a Langfuse Cloud base URL.

View file

@ -47,26 +47,26 @@ processors:
- key: librechat.langfuse.destination
action: delete
batch/central:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
batch/by_auth_eu:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
metadata_keys: [authorization]
metadata_cardinality_limit: ${env:LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT}
batch/by_auth_us:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
metadata_keys: [authorization]
metadata_cardinality_limit: ${env:LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT}
batch/by_auth_jp:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
metadata_keys: [authorization]
metadata_cardinality_limit: ${env:LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT}
batch/by_auth_hipaa:
timeout: 1s
send_batch_size: 128
timeout: ${env:LANGFUSE_FANOUT_BATCH_TIMEOUT}
send_batch_size: ${env:LANGFUSE_FANOUT_BATCH_SEND_SIZE}
metadata_keys: [authorization]
metadata_cardinality_limit: ${env:LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT}