When Langfuse trace sampling controls ingestion volume
Trace sampling is the right lever when the volume of traces entering your self-hosted Langfuse is the problem, not how long they are kept. If ClickHouse disk and ingestion load are rising faster than your team can absorb, sampling reduces what is written at the source. If the growth is steady and within what you can store, the better move is usually to review retention and capacity instead. Sampling is client-side. You set LANGFUSE_SAMPLE_RATE in the application's environment, or the sample_rate or sampleRate constructor parameter in the SDK, with a value between 0 and 1. The default is 1, which keeps every trace.
Sampling applies per trace, not per observation or score. When the SDK decides to keep a trace, every observation and score attached to that trace is kept, so a multi-step agent run is either fully recorded or absent. This matters for evaluation coverage. A rate of 0.2 keeps roughly one in five traces, which means any evaluator, dataset run or quality review built on traces sees a fifth of the traffic. Before you choose a rate, confirm which evaluators and dashboards depend on complete traffic, and whether low-volume, high-value flows such as failed requests or specific customers should be exempt from sampling. Sampling decisions live in each application, so you also need to confirm that every service writing to the instance uses the same setting.
Sampling is not a substitute for a retention policy. It limits how much new data arrives, but it does nothing to data already stored, and retention controls how long stored data remains. Use sampling when the ingestion rate or ClickHouse growth is the constraint, and use retention when storage age is the constraint. Many teams need both. Check the Langfuse sampling documentation for the current behavior before you roll out a rate, and test the chosen value in a staging environment so you can measure the effect on trace counts and evaluation results before production traffic is affected.
Sampling options and when each fits
This table compares the environment variable and constructor parameter that set the client-side sample rate, the default of 1, and what the 0 and fractional settings do to evaluation and cost coverage. Read each row as a decision: where the rate is set, which environments it suits, and what coverage you give up. The main takeaway is that sampling reduces what reaches ClickHouse, so confirm evaluation needs before lowering the rate in production.
| Option | What it does | Effect on evaluation and cost | When it fits |
|---|---|---|---|
| LANGFUSE_SAMPLE_RATE (environment variable) | Sets the client-side sample rate between 0 and 1 for every SDK client that reads it at startup | Lowers trace volume sent to your instance for all code paths in that process; scores on dropped traces are dropped too | Uniform setting per deployment, such as one container image promoted across environments with a different value injected per environment |
| sample_rate or sampleRate constructor parameter | Sets the rate on a specific client instance in code, overriding the environment default | Same trace-level effect, limited to the client that sets it; other services keep their own rate | One service or pipeline is high volume while others must stay fully traced, or a feature flag changes the rate at runtime |
| Default of 1 | Keeps every trace; no traces are dropped by sampling | Full evaluation coverage and the highest ingestion and ClickHouse growth | Development, low-volume workloads, and any production traffic you have not yet sized |
| Rate of 0 | Drops all traces on that client | No traces, observations or scores from that client reach Langfuse, so no evaluation coverage | Turning tracing off temporarily for a service without removing instrumentation code; confirm this does not hide incidents |
| Fractional rate between 0 and 1 | Keeps a random share of traces, decided per trace so each kept trace retains all its observations and scores | Reduces volume roughly in proportion, but evaluations, datasets and cost reports see only the sampled traces | Production traffic where a representative subset is enough for monitoring, and staging where full coverage is not needed |
| Per-environment rates (staging versus production) | Lower rate in staging or development, higher or default rate in production | Staging keeps trace volume low; production keeps the coverage that your evaluation and cost reporting depend on | Teams that need full production evidence for review while limiting nonproduction growth |
How to configure sampling in your application
This sequence turns a volume problem into a tested setting: you pick the traffic to sample, set the rate per service, deploy, and confirm that fewer traces reach ClickHouse while every kept trace stays complete.
Confirm the SDK version supports sampling
Before changing anything, the team that owns each service checks that the Langfuse SDK version in use exposes the sampling setting, either as the LANGFUSE_SAMPLE_RATE environment variable or the sample_rate (Python) or sampleRate (JS/TS) constructor parameter. Check the SDK changelog and the sampling documentation for the version you run, and note the exact parameter name. If the parameter is missing, upgrade the SDK in a test environment first, since SDK and self-hosted Langfuse versions can have minimum requirements. The step is done when each service has a recorded SDK version and a confirmed parameter name.
Decide which traffic is high volume
Review trace counts per service, route, model and environment for a representative period, using the Langfuse dashboards or your own logs. Mark the flows that produce most of the volume and little unique analytical value, such as health checks, repeated retrieval calls or batch jobs that run the same prompt thousands of times. Keep low-volume, high-value flows, such as user-facing conversations that feed evaluations, unsampled. Record the decision per service so that reviewers can see why each rate was chosen. The step is done when every service has a written sampling choice and the traffic it covers is named.
Set the sample rate for each service
The application team sets LANGFUSE_SAMPLE_RATE in the environment of each service, or passes sample_rate or sampleRate when it constructs the Langfuse client. The value is a number between 0 and 1, and the default is 1, which keeps everything. Set the rate per service rather than globally, so that a high-volume batch service does not reduce coverage for a user-facing service that drives evaluations. Commit the change through your normal configuration path so the rate is reviewable and reversible. The step is done when each service's configuration shows the intended rate and no service inherits an unintended one.
Deploy the change to a test environment first
The platform or application team deploys the updated services to a non-production environment that sends traces to a Langfuse project used for testing. Generate a known set of traffic, for example a fixed number of test requests, so the expected kept count can be estimated against the configured rate. Confirm that the service starts without configuration errors and that the sampling value appears where the team expects it. The step is done when the test deployment runs cleanly with the new rate and the traffic sample is ready for verification.
Verify that kept traces drop as expected
Compare the number of traces that appear in the Langfuse project for the test traffic with the number sent by the application. Across a large enough sample, the kept share should be close to the configured rate, but expect variation on small runs. Check the trace count in the UI or through the API, and confirm that the change is visible in your ingestion dashboards. The step is done when the observed kept share is consistent with the configured rate for the test volume.
Check that sampled traces stay complete
Open several kept traces from a multi-step flow, such as an agent run with tool calls, and confirm that every observation and every score attached to each trace is present. Sampling is applied per trace, so a kept trace should keep all of its observations and scores, and a dropped trace should be absent entirely. Also confirm that dropped traces do not appear in the UI or in the API responses and that their scores are not orphaned. If you find partial traces, stop the rollout and check the SDK version and instrumentation before continuing. The step is done when the spot checks show complete traces and no partial or orphaned records.
Confirm evaluation coverage and roll out
Review whether the evaluations and dashboards that depend on trace volume still have enough data for their purpose, since fewer traces means fewer scored examples and smaller samples for each cohort. Agree the rate with the owners of each evaluation before promoting the change. Then roll out to production one service at a time, and record the rate, date and owner in your configuration history so later changes can be compared. The step is done when evaluation owners have accepted the coverage and each production service shows the verified rate.
What sampling costs you in evaluation coverage
Sampling lowers what you store and pay for, but every discarded trace is one your evaluators, dashboards and debugging workflows never see. The cards below cover the trade-offs to settle with your evaluation owners before you set LANGFUSE_SAMPLE_RATE, since each one changes what your numbers can be trusted to show.
Rare failures may never be recorded
Sampling is applied per trace, so a trace that was dropped leaves no observations, scores or errors in Langfuse. A failure that happens in one request in a thousand may be missing from the UI when an engineer goes looking for it. Before you choose a rate, ask which failure classes must be captured every time, such as safety refusals, tool errors or a specific customer tenant, and whether those need a separate instrumentation path.
Sampling docsSmaller samples for LLM-as-a-judge
LLM-as-a-judge and human annotation run on the traces that reach Langfuse, so a lower sample rate means fewer items to score. Judge cost and annotator time fall with volume, but confidence intervals widen, and small slices such as one language or one prompt version may end up with too few scored traces to compare. Confirm with your evaluation owners the minimum number of scored traces per slice they need before they will act on a result.
Skewed metrics and cost dashboards
Token counts, latency percentiles, error rates and spend shown in Langfuse reflect only the sampled traces unless you correct for the rate yourself. A 10 percent sample reports one tenth of the spend if nobody scales it back up, which can mislead budget owners. Decide whether dashboards will show raw sampled totals or extrapolated figures, and label them so finance and platform teams read the same number.
Sampling by trace, not by user or session
Because the rate applies to each trace independently, one user session can contribute some traces and lose others. Multi-turn conversations, agent runs and session-level scores can then look incomplete, and a session that was partly sampled may distort per-user cost and quality views. If your analysis is organized around sessions or users, test how sampling interacts with that grouping before you rely on it.
Harder comparisons across releases
A prompt or model change compared against a baseline only works if both periods were sampled at the same rate and selected the same way. If you change LANGFUSE_SAMPLE_RATE during a rollout, release-over-release comparisons, regression experiments and alert thresholds all shift. Record the rate in each release note and keep it fixed for the window you compare, or compare against a dataset run rather than production traffic.
Data retention still applies to the kept traces
Sampling reduces what enters ClickHouse, but it does not change how long the traces you keep are stored. Your retention window and deletion obligations apply equally to the sampled subset, so a lower rate is not a substitute for a retention policy when a data protection review asks how long personal data stays. Confirm the retention window with your privacy and compliance owners, and treat sampling as a volume control only.
Sampling or shorter retention: choosing the right lever
Sampling and retention both reduce what your Langfuse deployment holds, but they act at different points. Sampling decides what gets written at ingestion: with LANGFUSE_SAMPLE_RATE set below 1, the SDK keeps only a share of traces and discards the rest before they reach your server. Retention decides how long data that was already stored stays in ClickHouse before it is removed. Sampling therefore limits growth from the start, while retention limits how far back history reaches. Because the two work on different stages, they answer different questions, and choosing between them starts with asking which question you are actually trying to answer.
Sampling fits high-volume, low-risk traffic, such as a chatbot answering routine product questions where a representative slice of traces is enough to spot quality regressions and cost trends. It is also a reasonable choice when you need evaluation coverage rather than every individual request. The trade-off is that dropped traces are gone: they cannot be scored, reviewed or replayed later. Shortening retention or archiving fits better when you must keep complete history for a compliance window, investigate individual incidents, or reconstruct what a user saw. In those cases, cutting ingestion removes the very records you may need, so the lever should act on how long data lives instead. Confirm with your compliance and security teams which records must be complete before you sample anything.
Retention and scheduled export are separate controls that you should review alongside sampling. Per-project retention behavior, including what the nightly cleanup deletes and what it leaves in place, is covered in the retention topic, and archiving stored observations and scores to blob storage on a schedule is covered in the export topic. Read both before deciding, and check the current Langfuse documentation on Langfuse sampling for how the sample rate applies to each SDK you run. A practical approach is to sample the traffic whose loss you can accept, keep full retention for the projects under audit, and archive what you must preserve before it expires.
How a sampled trace moves from the SDK to ClickHouse
The diagram starts in your application, where the Langfuse SDK decides per trace whether to send it, based on the client-side sample rate. A kept trace travels to Langfuse Web, which accepts the ingestion, then to Langfuse Worker, which processes it and writes it to ClickHouse. A dropped trace stops at the SDK and never leaves your application. Check that the sample rate is set in the SDK configuration of each service, because sampling does not happen on the server.
Sampling decides per trace in the SDK, so dropped traces never reach Langfuse.
Security and operational considerations
Sampling is a configuration change with security and operational effects, so it needs the same ownership and review as other settings. The cards below cover where the control runs, what it does not protect, and how to confirm the change is working after it ships.
Sampling runs in client code
Sampling is applied by the SDK inside each application, not by the Langfuse server. That means the sample rate is only as controlled as the deployed configuration of every service that sends traces. Treat LANGFUSE_SAMPLE_RATE as a production setting with a named owner, and check that the value a service runs with is the value the owner approved. A rate set in a local .env file or a test pipeline can quietly reach production.
Sampling does not remove sensitive content
A trace that is kept is kept whole, so prompts, outputs and user data inside it reach your Langfuse instance exactly as they would without sampling. Lowering the rate reduces how many traces hold personal data, but it does not scrub any individual trace. Masking is a separate control that must be configured on its own, and the reviewer of a sampling change should confirm that masking is still in place for the traces that remain.
Document and review every rate change
Record each sample rate, the services it applies to, the reason for it, the approver and the date it took effect. A reviewer should check that a change does not silently drop traces needed for security investigations, incident review or the evaluations your team depends on. Keep the record with your change management process so auditors and internal reviewers can see what was sampled and why.
Keep the rate consistent across services
Each service that sends traces sets its own rate, so two services can run at different values without anyone noticing. Inconsistent rates make dashboards, cost reports and evaluation scores hard to compare. Inventory every SDK integration that sends to your Langfuse project, record the rate each one uses, and confirm that the values match the approved policy after each deployment.
Monitor ingestion after each change
Measure trace volume and ClickHouse disk growth before and after a rate change, over a period long enough to cover normal traffic patterns. Confirm the drop matches what the new rate should produce, and watch for services that did not pick up the change. Watch evaluation coverage too, because fewer traces means fewer scored items. Ask your operations team which dashboards and alerts will show these effects before the change goes live.
Questions teams ask before sampling traces
Does trace sampling lower the cost of a self-hosted Langfuse?
Yes, sampling lowers the volume of data your Langfuse deployment ingests, which reduces the ClickHouse disk, memory and worker CPU that the platform needs over time. The size of the saving depends on what share of traffic you drop, how many observations each trace carries, and how large your payloads are. Your infrastructure bill also includes PostgreSQL, Redis or Valkey, blob storage and the compute for the web and worker containers, and sampling only touches the ClickHouse part directly. Ask your team to measure current daily ingestion per project before choosing a rate, so the expected reduction can be checked after rollout.
How long does a sampling rollout take, and what does it need from our team?
The configuration change itself is small: you set LANGFUSE_SAMPLE_RATE or the sample_rate or sampleRate parameter in each client and redeploy the application. The longer part is deciding the rate, which needs agreement from the engineering owner, the team that relies on traces for debugging, and whoever runs evaluations. Plan for a measurement period in a staging environment, a comparison of ingestion and evaluation coverage, and a clear rollback path. Duration depends on how many services and SDK clients you run and how many teams must sign off, so confirm the scope with your own platform team before setting a date.
Can our own engineers configure trace sampling without a partner?
Yes, sampling is a client-side setting, so any team that owns an application instrumented with the Langfuse SDK can configure it without changing the Langfuse server. The work that usually needs care is governance: deciding which applications sample, which rates apply to which environments, and how the setting is recorded in configuration management. Teams without a platform owner often set one rate everywhere and forget it. If you want an outside review of the design, DeployOpen can plan and implement it as part of a fixed-scope engagement, with the scope agreed in writing before work starts.
Does sampling affect evaluations and scores?
Yes, sampling reduces evaluation coverage because a trace that is not sampled is not sent, so its observations and scores never reach Langfuse. Sampling is applied per trace, so all observations and scores inside a sampled trace are kept together, which keeps each retained trace complete. Evaluations that run on a sample of production traffic will therefore see a subset of requests. Before choosing a rate, confirm with the team that owns your evaluations whether that subset is representative enough for the questions they ask, and whether any regression tests need a separate, unsampled path.
Should we sample traces or shorten data retention to control growth?
Use sampling when the problem is the volume of traces you need to ingest, and use shorter retention when the problem is how long you keep data you already have. Sampling reduces what enters ClickHouse, so it also reduces what retention must later delete, but it removes data permanently at the point of capture. Retention keeps full fidelity for a shorter window and is usually easier to justify for debugging recent incidents. Many teams combine the two, sampling noisy high-volume applications while keeping a defined retention window for the rest. Confirm your compliance and audit requirements for retained trace content before deciding, since reducing retention may be the only control that matches a documented policy.
Will sampling hide the traces we need during an incident?
It can, because a sampled-out request is never stored, so you cannot look it up later. Lower rates make it more likely that a specific user's failing request is missing from Langfuse. Reduce this risk by sampling by application or environment rather than uniformly, keeping full capture for production error paths where your SDK integration allows it, and keeping application logs that record request identifiers independently. Ask your team to define which incident workflows must work with the sampled data before rollout, and test one of them in staging.
How do we check that sampling works after we turn it on?
Compare ingestion volume and trace counts for each project before and after the change, using the same period of the week so traffic patterns match. Confirm that retained traces still contain complete observations and scores, since sampling keeps whole traces. Check that the rate you set in each client matches the value in your deployment configuration, because drift between services is a common source of surprise. Record the rate in your change log so future operators can explain why trace counts changed.
Limits to confirm in your environment
Client-side sampling changes what your traces, scores and datasets contain, and the exact behavior depends on the SDK and instrumentation path each team uses. The cards below list the points to verify in a test environment before you set a rate in production.
SDK versions with the sample rate parameter
Confirm that the SDK version each team runs accepts the sample rate setting, whether through LANGFUSE_SAMPLE_RATE or the constructor parameter. An older SDK may ignore the setting, which means traces are still sent at full volume and your ingestion estimate is wrong. Check the version in every service before you assume a reduction. Record the version in your deployment inventory so upgrades do not silently change behavior.
Behavior across every language SDK
Sampling is applied on the client, so each language SDK your teams use must be tested separately. Python, JavaScript and TypeScript services, and any other SDK in use, may differ in how and when they apply the rate. Run the same test trace through each one and confirm that the sampled share in the Langfuse UI matches the configured rate over a meaningful number of requests.
OpenTelemetry export paths
Traces that arrive through the OTLP endpoint at /api/public/otel may follow a different path from traces sent by native SDK calls. Confirm whether the rate applies to OpenTelemetry-instrumented frameworks such as LangChain or LlamaIndex, and whether the collector or application code is the place where sampling happens. Do not assume one setting covers both paths.
Evaluation and dataset coverage
A sampled trace keeps all its observations and scores, but traces that were dropped will never reach online evaluators, annotation queues or dataset construction. Decide which traffic must always be captured, such as failures or flagged sessions, and confirm that your evaluation workflow still gets enough traces to measure quality. Sampling for cost and sampling for quality measurement are different goals and may need different rates.
ClickHouse headroom during migrations
Reducing ingestion does not free disk if you are also moving to a new data model or backfilling history. The v3 to v4 upgrade guide advises about 3x ClickHouse disk headroom when backfilling historic data, so confirm your storage capacity against that guidance before a migration, not after. Ask your DeployOpen or internal team to measure free space at the planned rate and at full volume, and to define a rollback point before the upgrade starts.
v3 to v4 guideHow DeployOpen scopes and supports trace sampling
DeployOpen scopes trace sampling as part of a fixed-scope self-hosted Langfuse engagement. The scope note records which applications send traces, which environments are sampled, the sample rate each application uses (set through LANGFUSE_SAMPLE_RATE or the SDK constructor parameter), and how the team will confirm that sampled traces still cover the evaluations, prompt tests and cost reports the organization relies on. Because sampling happens in the client, the scope also names the services and SDK versions that must be changed and tested. Rates and verification steps are agreed in writing before any work starts, so the people who own evaluation coverage and spend can review the trade-off before it reaches production.
Verification is part of the agreed work, not an afterthought. Typical checks confirm that each sampled application honors the configured rate, that whole traces are kept or dropped together, and that the ClickHouse growth and token-spend figures moved in the expected direction after the change. Where a sampling decision also affects a retention decision, the written scope should say which one is being used and why. Teams that plan a retainer can ask for periodic reviews of rates as traffic and use cases change. DeployOpen does not issue audit reports or attestations for the resulting configuration. Independent auditors and certification bodies do that work, and DeployOpen can prepare the evidence they request.
DeployOpen does not publish a price list for sampling work. A quote follows from the written scope, so ask for the applications and environments in scope, the verification steps, the handover of configuration and runbooks, and whether ongoing review is included in a retainer or priced separately. Ask the vendor or your own platform team to confirm the current Langfuse release and SDK versions that support the sampling setting in your environment before the scope is finalized.

