Building Langfuse datasets from production traces: when your team needs real test cases
A Langfuse dataset built from production traces is a versioned collection of test items, each drawn from a real trace your application already recorded, with an input and, where you have one, an expected output. Teams use these datasets for regression testing because they measure a change against the questions users actually asked, not against prompts a developer wrote while building the feature. When a prompt, model or retrieval step changes, the same items can be run again and the scores compared, which shows whether the change helped the cases that matter or quietly broke some of them.
Datasets are a self-hosted feature available in the MIT-licensed core of Langfuse, so you do not need an Enterprise license key to create them, add items or run experiments against them. The software is the easy part. The real work is selecting which traces deserve to become test cases, reviewing each item so that it is correct and representative, writing expected outputs where a fixed answer exists, and maintaining the set as the product and its users change. Confirm this scope against the current Langfuse self-hosting documentation before you plan the build, since features and plan boundaries can move between releases.
Before anyone selects traces, agree who owns the dataset, how often items are reviewed and what triggers a removal. Ask your team to decide whether the set should cover common requests, edge cases or past failures, because that choice changes the sampling rules and the review effort. Plan for sensitive content from the start: traces often contain personal data, and the items you copy into a test set are a second copy of that data. Settle these decisions first, then build the selection workflow, so the dataset stays useful and defensible as traffic grows.
How a production trace becomes a dataset item
The flow starts in the application, which sends traces to self-hosted Langfuse through the SDK or the OTLP endpoint. A reviewer then inspects those traces and decides which ones are worth keeping. Before a trace becomes a dataset item with an expected output, it passes a review and redaction step, which is the trust boundary: personal data and secrets should be removed or masked there, not after the items are used in experiments. Check that every item has an expected output and that redaction ran before the item was saved.
Production traces move through review and redaction into a dataset before any experiment runs.
Choosing which traces become dataset items
Manual curation means an engineer or domain expert opens traces in the Langfuse trace view and adds the ones they judge worth keeping as dataset items. It suits early datasets, where the team is still deciding what good behavior looks like, and rare, high-stakes cases that no filter would find on its own. The method gives the most control over each item, but every item costs reviewer time, so the dataset grows only as fast as people can read traces.
- Reviewer time: Each item needs someone to read the input, judge the output and write the expected output, so cost scales with the number of items.
- Selection bias: Reviewers tend to pick traces that look interesting, which can overrepresent unusual prompts and miss routine traffic.
- Consistency: Two reviewers may disagree on what the expected output should be, so write a short rule for the team before curating.
- Traceability: Record which trace an item came from and who added it, so later reviews can explain why the item exists.
- Sensitive content: Reviewers see raw user input, so check for personal data before an item is copied into a shared dataset.
Before relying on a manually curated set, confirm how your team will sample routine traffic alongside the hand-picked cases.
Selection by filters or scores pulls traces in bulk using attributes such as model, prompt version, user segment, tags, time range or existing evaluation scores. It suits building larger sets quickly, such as all traces where a judge or user feedback score was low, or a stratified sample across prompt versions. The cost moves from reading each trace to designing the filter well, and the risk moves from missed cases to a sample that reflects the filter rather than your traffic.
- Reviewer time: Lower per item, but reviewers still need to check a sample and write expected outputs for the items they keep.
- Biased samples: A filter on one user group, region or product feature produces a dataset that tests only that group, so experiments can look better or worse than they are.
- Feedback loops: Selecting only traces with low scores builds a set that tests known failures and may hide new failure modes the scorer does not detect.
- Score quality: A filter is only as good as the score it uses, so check the scorer's own accuracy against human labels first.
- Stratification: Sample across the dimensions that matter, such as user segment and prompt version, and record the sampling rule with the dataset.
Before running a filter at scale, confirm which attributes and scores are present on your traces in your own instance, since missing metadata silently narrows the selection.
Programmatic creation adds traces to a dataset through the Langfuse API or SDK, usually from a job that runs on a schedule or from application code that flags a request. It suits repeatable pipelines, regular refreshes of a regression set, and teams that already keep their selection rules in code and review them like other changes. Reviewer time moves to the rules and to periodic spot checks, while the main risk is that a rule encodes assumptions nobody questions.
- Upfront effort: Engineers must write, test and maintain the selection logic, and this work recurs when schemas or prompt formats change.
- Repeatability: The same rule produces the same selection on each run, which makes dataset history easier to explain.
- Data handling: Code can strip fields, mask values or skip records before they reach the dataset, but only if someone writes and tests those steps.
- Drift: Rules built around today's traffic can quietly stop matching tomorrow's, so schedule a review of selection criteria.
- Access: Limit which service accounts and keys can write to datasets, and log changes.
Before automating selection, confirm the exact SDK version your instance supports and test the job against a staging project first.
Writing expected outputs that tests can judge
An expected output tells a test what a good result looks like, so every item needs a decision about how that standard is written down. The cards below cover the choices that determine whether a dataset stays useful as production traffic changes and reviewers rotate.
Exact string or rubric
An exact string works for classification labels, extracted fields and fixed JSON shapes, where one correct answer exists. Free-form answers rarely match word for word, so for summaries, explanations and advice, write a rubric that lists the facts the answer must contain and the claims it must not make. Mixing the two styles in one dataset makes scores hard to compare. Check that each item's expected output matches the evaluator you plan to run against it.
When no expected output is needed
Some checks do not need a reference answer. A JSON validity check, a regex for forbidden content or a rule that a tool call uses an allowed argument can judge the output alone. Leaving the expected output empty for these items keeps the dataset from filling up with values that no one reviews. Record the evaluator name in the item metadata so the next reader knows why no reference exists.
Who writes and approves the value
The person who writes an expected output should not be the only person who approves it, especially when the answer depends on policy or domain knowledge. Assign a named owner for each dataset, and record who wrote and who approved each value. Ask domain experts to review a sample of production-derived items before they enter a regression suite. Confirm with your team how approvals are recorded, since Langfuse stores the dataset items but your review process lives outside the product.
Multi-turn sessions
A single trace rarely captures a full conversation, so decide whether each dataset item covers one turn or a whole session. For one-turn items, the expected output should reflect the conversation history included in the input. For full sessions, define the expected outcome at the end, such as a resolved ticket or a completed booking, and check each intermediate turn separately. Document the history you kept, because truncated context can make a correct turn look wrong.
Recording prompt input variables
A prompt often uses variables such as a customer tier, a retrieved document or a locale. If the dataset item omits one of them, a prompt experiment fills the gap with an empty value and the score reflects that gap, not the prompt. Store every variable the prompt reads under the same keys in the item input, and check that the names match the prompt version you plan to test. Confirm with your application team which variables are set at runtime and which are derived.
How dataset versions keep experiments comparable
An experiment is only a fair comparison if every run scores the same inputs and expected outputs. When dataset items are edited, added or removed between runs, a score change may reflect the test set rather than the prompt or model you are testing. Before you compare runs, decide how your team will freeze the test set for the duration of a comparison, and confirm how your Langfuse instance records dataset versions, since the exact behavior should be checked against the current Langfuse docs and the version you run (the v4 line is documented at Langfuse self-hosting docs).
Teams pin a dataset version so that a prompt or model comparison runs against a known, unchanging set of items. In practice, this means recording which version each run used, reusing that version when you test a candidate change, and treating any edit to the items as a new baseline. A run that used a different dataset version is not directly comparable to one that used another, even if the run names look identical. Ask your Langfuse administrators to confirm how versions are selected in the UI and the SDK, because a run that silently pulls the latest items will break the comparison without any visible error.
Create a new dataset instead of editing one when the test purpose changes, not when items are merely corrected. Examples include a new product area, a different language, a shift to a new output format, or a set of items drawn from a different traffic period (illustrative). Keeping the old dataset intact preserves the history your team uses to judge regressions. Record the reason for each new dataset in your team's documentation, along with its source traces and who approved the items, so that a future reviewer can tell why two datasets differ.
Keeping personal and sensitive data out of test data
What personal data can end up in Langfuse traces and dataset items?
Anything the application sends to the model or receives back can end up in a trace, and a dataset item built from that trace copies whatever it contains. Common examples include names, email addresses, phone numbers, account or patient identifiers, payment details, free-text complaints, and secrets such as API keys pasted into prompts. Tool calls and retrieved documents are easy to overlook because they often carry more data than the user's visible message. Before you build a dataset, list the fields your application sends to the model and the fields returned by tools and retrieval, then decide which of them a test actually needs. Ask your privacy team to confirm which categories count as personal data under the laws that apply to you.
Does Langfuse mask personal data before it is stored?
Server-side data masking is an Enterprise feature, so a self-hosted instance only gets it with a license key. Without that key, you should not assume that the platform masks personal data for you. Confirm with the Langfuse documentation for your version how masking is applied, where it runs, and whether it covers traces, observations, dataset items and exports. Then test it on a non-production instance using sample data that resembles yours. Treat masking as one layer. Keeping sensitive fields out of the data you copy into datasets is still the most reliable control, because it does not depend on a setting being correct.
Does server-side data masking require an Enterprise license key?
Yes. Langfuse lists server-side data masking among the self-hosted features that need an Enterprise license key, alongside project-level RBAC roles, data retention policies, audit logs and the instance management API. Core features and APIs are available in the MIT-licensed open source version. The Langfuse license key documentation explains how keys are issued and applied. Our Langfuse features page is not the right place for this list, so use the Langfuse features content on DeployOpen for the full set of Enterprise-only controls and what each one does for retention, deletion and access.
How do I redact sensitive fields when creating dataset items from traces?
Build the dataset item from a copy of the trace fields your test needs, and replace identifiers before the item is written. Good practice includes:
- Remove or replace direct identifiers such as names, emails, account numbers and free-text notes with stable placeholders like
<CUSTOMER_1>. - Keep the mapping from placeholders to real values outside Langfuse, in a system with its own access controls.
- Drop tool outputs, retrieved documents and metadata fields that the test does not use.
- Review expected outputs too, since a reviewer may have typed personal details into them.
- Log which script or person created each item so you can trace it later.
Write the redaction as code in your dataset-building pipeline so it runs the same way every time, and test it against sample traces that contain known sensitive values.
How do I remove dataset items when someone asks for deletion?
Start by finding every place a copy of the person's data lives, which usually includes the source traces, the dataset items built from them, any dataset versions that still hold older copies, and experiment runs that reference those items. Then confirm in your Langfuse version which deletion options exist for each object and whether deleting an item also removes it from earlier versions. Document the steps in a runbook, test them on a non-production instance, and record each request and the time it was completed. Ask your team to confirm how backups and blob storage copies are handled, since they can keep data after it is deleted from the application. Your retention settings and deletion process should be checked against your own obligations with legal counsel.
Who should review test data for sensitive content, and how much effort does it take?
The team that owns the dataset should own the review, with privacy or security staff approving the redaction rules and sampling the output. Effort depends on how many traces you import, how varied your inputs are, and whether the content is free text. Free text such as support messages takes far more review than structured records. Expect costs in several places: engineering time to write and test the redaction code, reviewer time for spot checks, and recurring work each time the application adds a new field or tool. Ask any partner to show how the review is scoped, who signs off, and how changes to redaction rules are versioned and tested.
Can DeployOpen help design redaction and deletion workflows for self-hosted Langfuse?
DeployOpen plans, implements, configures, hardens, backs up and documents self-hosted open-source platforms inside the client's own infrastructure, including self-hosted Langfuse. Redaction rules, dataset-building pipelines, deletion runbooks and the Enterprise controls that apply to your edition can be covered in a fixed-scope engagement, with scope, deliverables and timelines agreed in writing before work starts. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications, and it cannot promise that your data handling meets a specific legal standard. Your legal and privacy teams remain responsible for those judgments. A quote follows from the written scope.
Does keeping personal data out of datasets remove GDPR obligations for traces?
No. Removing personal data from datasets reduces what you copy and keep for testing, but it does not by itself settle the obligations that apply to the traces in your production instance. The traces, the backups and any exports still have to be handled under your retention, access and deletion policies. Treat redaction in datasets as one measure among several, and have your privacy team map which data categories, lawful bases and retention periods apply to each store. A separate content group in this section of DeployOpen covers how Langfuse retention, deletion and masking features support GDPR work, so read it alongside your legal review.
Setting up a dataset workflow from production traffic
This sequence turns live Langfuse traces from your self-hosted instance into a versioned dataset that your team can use as a regression baseline. Each step ends with a check, so you know the dataset is trustworthy before any experiment relies on it.
Confirm tracing reaches the self-hosted instance
Before building anything, confirm that your application sends traces to your self-hosted Langfuse and that the traces show the inputs, outputs, model names and nested observations you expect. Your platform or application team should run a few representative requests through each production path, including the paths that call tools or retrieve documents. The step is done when every expected path appears as a trace in the correct project, and you have written down which environment and project the traces came from.
Define the dataset schema and naming
Decide what a dataset item will contain: the input fields your application or prompt reads, the expected output field, and any metadata such as source trace ID, product area or user segment. Write a naming convention for the dataset and its items, and record which fields are required. Ask the team that owns the evaluators to review the schema, since their checks must read the same keys. The step is done when the schema is written in a shared document and a test item with every field populated can be created and read back.
Select and review a first batch of traces
Filter production traces for a narrow, representative slice, such as one workflow, one prompt version or one month of traffic, and pick a first batch that covers common requests and known failure cases. Review each candidate by reading its input and output, and exclude traces with personal data, credentials or content you are not permitted to retain for testing. Record the filter used so the batch can be reproduced. The step is done when the reviewed batch is saved with its filter criteria and a list of excluded traces with reasons.
Remove sensitive data before adding items
Apply redaction to every candidate item before it enters the dataset. Replace personal identifiers, account numbers, secrets and free-text fields that contain customer details with placeholders or synthetic values, and confirm the masking rules you rely on for production traces also cover the dataset copy. Check that redacted fields are absent from the item JSON, not just hidden in the interface, by exporting or fetching a sample of items through the API. Ask your compliance or privacy lead to approve the redaction rules before the batch is loaded. The step is done when a spot check of sampled items shows no removed values.
Write expected outputs for each item
For each reviewed item, write the expected output or the properties a correct answer must have, such as required fields, a required decision or a reference answer. Domain experts should write or approve these expectations, because a baseline built on unchecked model output will reward the same errors. Store the expected output in the dataset item's expected field and keep any rubric notes in metadata. The step is done when every item has an expected output or an explicit note that it is scored by properties only, and a second reviewer has signed off on a sample.
Add items and confirm counts
Add the reviewed, redacted items to the dataset through the Langfuse interface or SDK, and keep each addition linked to its source trace. Compare the number of items in the dataset with the number of approved rows in your batch record, and check that no item is duplicated or missing its expected output. Create a dataset version or note the version identifier so the batch can be referenced later. The step is done when the item count matches the approved batch, a sample of items reads back with the expected fields, and the version is recorded.
Run a baseline experiment
Run the current application or prompt against the dataset as an experiment, with the evaluators the team agreed on, and save the result as the reference run. Review the run to confirm that every item executed, that scores exist for every item and that failed items are explained rather than silently dropped. Keep the run name, dataset version and application version together so later comparisons are valid. The step is done when the baseline run is complete, its scores are readable, and the team has agreed on what counts as a regression.
Set a review cadence for the dataset
Assign an owner for the dataset and agree on how often new production traces are reviewed, redacted and added, and when old items are retired because the product or prompt has changed. Each refresh should create a new dataset version and a new baseline run, so results remain comparable. Confirm the cadence with the team responsible for retention and deletion settings, since item copies must follow the same policy as traces. The step is done when the owner, cadence, and refresh checklist are documented and the next refresh date is on the team calendar.
Security and data handling for trace-derived test sets
Dataset items copy trace content into a second place where it can be read, kept and backed up. The cards below cover the controls that decide who sees that copied data, how long it lives, what the backups hold and what evidence you can produce, and which of those controls need an Enterprise license key.
Limit dataset access by project role
Datasets sit inside a project, so anyone who can read the project can usually read its dataset items and the traces they came from. Project-level RBAC roles, which need an Enterprise license key, let you separate viewers, annotators and editors. Without them, plan access at the project boundary: put traces with sensitive content in projects that only the right team can open, and confirm how your version handles role changes for existing members.
License key docsKeep copied data on its own retention clock
A dataset item is a copy, so deleting or expiring the source trace does not automatically remove the item. Decide whether test items should outlive production traces and document that decision. Data retention policies, which need an Enterprise license key, can enforce expiry on traces, but confirm with your operators whether they reach dataset content before you rely on them for deletion requests.
Plan backups for dataset content
Dataset items live in PostgreSQL and ClickHouse, so every backup of those stores holds the same sensitive text that was copied into test sets. Restoring an older backup can bring back items you deleted, which matters for deletion requests. Ask your team to define backup retention, encryption and restore access for both stores, and to test that a deleted item stays deleted after a restore.
Self-hosting docsMask sensitive fields before copying
Masking at the point of copy is the most reliable way to keep personal data out of test sets, because nothing downstream can unmask what was never stored. Server-side data masking needs an Enterprise license key. Without it, strip or pseudonymize fields in your application or the script that builds the dataset, and check a sample of items for names, account numbers and secrets before sharing a dataset.
Expect an audit trail for changes
Auditors and security reviewers usually ask who created, edited or deleted a dataset and when. Audit logs need an Enterprise license key, so a core-only deployment needs another record, such as a change process in your git repository or a log of the scripts that write items. Confirm which dataset changes your deployed version records before promising an audit trail to a reviewer.
License key docsSeparate test data from production controls
A dataset built from production traces inherits production sensitivity, yet it is often shared with developers and CI jobs that have looser access. Set rules for who may export datasets, which environments may receive them and whether CI runners can read them. Core features and APIs are available in the MIT-licensed version, so these rules are an operating decision rather than a license purchase.
Questions teams ask before building datasets from traces
How much does it cost to build a Langfuse dataset from production traces?
The cost is mostly people's time, plus the infrastructure you already run for Langfuse. The main line items are engineer time to select traces and script the import, reviewer time to write expected outputs, and time for a privacy reviewer to agree redaction rules. Langfuse's core features, including datasets, are available in the MIT-licensed open source version, so the software itself adds no license fee. Costs rise with the number of task types, the amount of judgment needed per expected output, and how many reviewers must agree. Ask any partner for a fixed-scope quote that lists each item, its owner and what is one-time versus recurring, such as periodic refreshes of the dataset.
How long does it take to turn traces into a usable dataset?
Duration depends on how many traces you need, how many task types they cover, and how quickly reviewers can write expected outputs. A first dataset for one application is usually a matter of weeks of part-time work for a small team, but the exact time depends on your approvals and data access, which you should confirm in your own environment. The fastest path is to start with one narrow workflow, prove the import and review steps, then expand. Ask for a timeline tied to written milestones rather than a single end date.
What does the team need to provide for this work?
You need four things: access to the Langfuse project that holds the traces, an owner who understands what a correct answer looks like for each task, reviewers who can judge outputs, and a privacy contact who signs off on what may enter test data. Engineers also need API keys with the right project scope and a place to store the dataset-building scripts under version control. Without domain reviewers, expected outputs tend to reflect what the model already produced, which makes the dataset less useful for catching regressions.
Can our own team build a Langfuse dataset without a partner?
Yes, a team with an engineer who knows the application and a reviewer who knows the domain can build a first dataset in house. The work is mostly scripting trace selection through the Langfuse API or SDK, writing expected outputs, and documenting dataset versions. A partner is most useful when the team lacks time, when traces contain sensitive data that needs a formal redaction design, or when the dataset must support CI experiments from the start. Decide based on who will maintain the dataset after the first build, since that recurring work is often the larger effort.
How many dataset items are enough to test a change?
There is no universal number. Enough items means every important task type, input variant and known failure mode has at least a few examples, so a regression in any of them would show up in an experiment. Start with the cases that broke before, the high-traffic paths and the edge cases your support team sees. Then check that the set is large enough that one or two unusual items cannot decide the result. Track coverage by task type rather than by raw count, and confirm the size with your evaluation owner before you rely on it for release decisions.
How do we keep sensitive data out of test datasets built from traces?
Set redaction rules before anyone selects a trace. Decide which fields are personal data, credentials, account identifiers or regulated content, and whether to remove them, replace them with placeholders or exclude the trace entirely. Apply the rules in the import script rather than by hand, so every item goes through the same filter. Keep the original traces protected under your existing access controls, and limit who can view the dataset. Self-hosted Langfuse offers server-side data masking and retention policies, but several of these controls need an Enterprise license key, so confirm which ones your plan includes before relying on them.
When is it worth bringing in a partner to build datasets from traces?
Bring in a partner when the dataset will gate releases, when traces hold personal or regulated data that needs a documented redaction design, or when your team cannot staff reviewers and maintenance. A partner can also help connect the dataset to experiments in code and CI, so regressions are caught automatically. Ask for a written scope that names the traces covered, the redaction rules, the review process, the dataset version policy and who maintains it after handover. DeployOpen implements and documents self-hosted Langfuse in your own infrastructure and can scope this work as a fixed-scope engagement.
How DeployOpen scopes dataset work for self-hosted Langfuse
DeployOpen plans and builds the dataset workflow for your self-hosted Langfuse instance, from choosing which production traces become test cases to handing your team a documented, repeatable process. Engagements are fixed-scope, so the sample selection, redaction rules and deliverables are agreed in writing before any work starts.
How we scope
- Review which applications, traces and use cases your team wants to turn into dataset items first
- Agree in writing how dataset items, expected outputs and dataset versions will be defined
- Confirm which fields in production traces count as sensitive and must be removed before reuse
- Record who approves new dataset items and who owns each dataset after handover
How we build
- Configure dataset schemas and input keys so they match the variables your applications and evaluators read
- Build the sampling and export steps that copy selected traces into dataset items under your access controls
- Add masking or redaction steps so personal data and secrets stay out of test data before items are stored
- Test that items load correctly, versions are recorded and experiments can run against the agreed datasets
How we hand over
- Document the dataset naming, versioning and item-review conventions your team agreed to follow
- Provide runbooks for adding traces, writing expected outputs and retiring outdated dataset versions
- Walk your engineers and evaluation owners through the workflow in your own Langfuse instance
- Deliver a written record of the scripts, configuration and access settings used in the build
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover
- Support can cover changes to dataset schemas when your applications or evaluators change
- Retainer scope, response expectations and review cadence are confirmed in writing before they begin
- Ask for a quote built from the written scope, since DeployOpen does not publish a price list

