DocuStore.io
Integration

Observability

Configuring Langfuse for LLM tracing and prompt management, plus Umami for web analytics.

DocuStore integrates Langfuse for LLM observability and prompt management, and Umami for web analytics. Both are self-hosted and included in the Docker Compose development stack.

Langfuse

Langfuse provides two capabilities:

  1. LLM tracing -- Every LLM call (summarization, NER, chat) is traced with input/output tokens, latency, model parameters, and prompt versions.
  2. Prompt management -- Production prompts are stored and versioned in Langfuse, allowing iteration without code changes.

Prompt Management

DocuStore prompts are managed in Langfuse rather than hardcoded. The PromptRepository port loads prompts by name, and the Langfuse adapter fetches them from the Langfuse API with caching.

Key prompts managed in Langfuse:

Prompt NameUsed By
page_summaryPage summarization
artifact_batch_summaryArtifact summarization (batch stage)
artifact_synthesisArtifact summarization (synthesis stage)
artifact_refinementArtifact summarization (refinement stage)
chat_system_factualChat synthesis (factual queries)
chat_system_comparativeChat synthesis (comparative queries)
chat_system_exploratoryChat synthesis (exploratory queries)
chat_system_compoundChat synthesis (compound queries)
chat_system_followupChat synthesis (follow-up queries)

YAML Fallback

If Langfuse is unavailable, set PROMPT_REPOSITORY_TYPE=yaml to load prompts from local YAML files instead. This is useful for offline development or environments without Langfuse.

# Use Langfuse (default)
PROMPT_REPOSITORY_TYPE=langfuse

# Use local YAML files
PROMPT_REPOSITORY_TYPE=yaml

Configuration

VariableDefaultDescription
PROMPT_REPOSITORY_TYPElangfusePrompt source: langfuse or yaml
LANGFUSE_HOSThttp://localhost:3000Langfuse server URL
LANGFUSE_PUBLIC_KEY(none)Langfuse public key
LANGFUSE_SECRET_KEY(none)Langfuse secret key

Development Setup

Langfuse runs as part of the Docker Compose stack with pre-seeded API keys:

LANGFUSE_HOST=http://localhost:3000
LANGFUSE_PUBLIC_KEY=pk-lf-docu-store-dev
LANGFUSE_SECRET_KEY=sk-lf-docu-store-dev

Access the Langfuse dashboard at http://localhost:3000 to:

  • View LLM call traces with input/output/tokens/latency
  • Edit and version prompts
  • Compare prompt versions side by side
  • Monitor cost and usage over time

LLM Tracing

Every LLM interaction is automatically traced. The chat pipeline wraps entire conversations in a TokenCounter context manager that captures prompt and completion token counts from LLM API responses.

Traces include:

FieldDescription
Model nameWhich model was used
Input tokensPrompt token count
Output tokensCompletion token count
LatencyWall-clock time for the LLM call
Prompt versionWhich Langfuse prompt version was used
MetadataQuery type, mode, conversation ID

Umami (Web Analytics)

Umami provides privacy-focused web analytics for the DocuStore frontend portal. It tracks page views, sessions, and user behavior without cookies and is fully GDPR compliant.

What Umami Tracks

MetricDescription
Page viewsWhich pages users visit
SessionsUnique visitor sessions
ReferrersHow users arrive at the portal
Browsers/OSClient environment distribution
Custom eventsFeature usage (search, chat, upload)

Setup

Umami runs as part of the Docker Compose stack alongside Langfuse:

# Both are started by:
make docker-up
# This runs docker-compose.yml + docker-compose-langfuse.yml

The Umami dashboard is accessible at its configured port. The frontend portal includes the Umami tracking script, which sends analytics data to the self-hosted instance.

Privacy

Umami does not use cookies, does not track personal information, and does not share data with third parties. All analytics data stays on your infrastructure. This makes it suitable for research environments with strict data handling requirements.

Request Timing

DocuStore includes built-in request timing for API performance monitoring:

ENABLE_REQUEST_TIMING=true
SLOW_REQUEST_THRESHOLD_MS=1000

When enabled, every API request is logged with its duration. Requests exceeding the threshold are flagged as slow in the logs, making it easy to identify performance bottlenecks.

Structured Logging

DocuStore uses structlog for structured JSON logging throughout the backend. Log entries include:

  • Request ID and correlation IDs
  • Search latency metrics (search.latency events)
  • Chat pipeline duration and step counts
  • Workflow execution events
LOG_LEVEL=INFO   # DEBUG, INFO, WARNING, ERROR
LOG_DIR=./logs   # Directory for log files

All log output is structured JSON, making it easy to ingest into log aggregation systems (ELK, Loki, Datadog) for production monitoring.