Langfuse data masking for prompts and outputs

Langfuse data masking removes personal and sensitive data from prompts and outputs before they are stored. This page explains the client-side and server-side options, the Enterprise license requirement, and the fail-open versus fail-closed decision.

On this page

When Langfuse data masking keeps personal data out of traces

Traces from LLM applications often carry more than the text you meant to log. Prompts and outputs can contain customer names, account numbers, health details or credentials pasted by a user or returned by a tool. Langfuse data masking is the set of controls that redacts or removes such values before they are stored in your self-hosted Langfuse, so the tracing platform does not become a second copy of sensitive data. It can run in two places: in the SDK inside your application, before anything leaves the process, or in a server-side callback that Langfuse calls on each OpenTelemetry trace object before it is written to ClickHouse.

Client-side masking is part of the open source feature set, so you can use it without an Enterprise license key. Server-side ingestion masking is an Enterprise feature. You enable it with the LANGFUSE_INGESTION_MASKING_CALLBACK_URL setting, which points at a service you run and operate. Confirm the license scope for your edition on the Langfuse license key documentation before you plan a budget or an architecture around the server-side callback, since that page lists the Enterprise features that require a key.

The two layers answer different risks. Client-side masking is the only layer that keeps data from leaving your application, which matters when sensitive values must never reach your infrastructure in transit. Server-side masking is a central safety net that catches data from every service that sends traces, including those teams have not yet reviewed. Decide which layer is authoritative for each data class before you write the masking rules, and make sure the callback owner, the SDK configuration and the test cases are all documented together.

Client-side SDK masking or server-side ingestion masking

This table compares the two masking layers Langfuse offers, showing where data is changed, which license applies and what each layer protects against. Read it to decide whether you need client-side masking, server-side masking, or both before sensitive data reaches ClickHouse.

QuestionClient-side SDK maskingServer-side ingestion masking
Where data is changedInside your application, before the SDK sends the traceIn Langfuse ingestion, after the trace arrives and before it is stored in ClickHouse
LicenseAvailable in the open source versionRequires an Enterprise license key
What it protects againstSensitive data leaving your application, including from Langfuse itselfSensitive data reaching storage from SDKs or integrations you have not changed
Configuration pointMasking function in your SDK setup in each applicationSet LANGFUSE_INGESTION_MASKING_CALLBACK_URL on the Langfuse deployment, pointing to your callback
Coverage across teamsOnly applications that adopt the masking codeEvery trace sent to the instance, regardless of SDK
Failure behaviorData is masked before sending, so no unmasked copy is transmitted by the SDKFails open by default (unmasked events are stored) unless LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED is true
Role in your designPrimary control where data must never leave the applicationCentralized safety net, not a replacement for client-side masking
When it fitsRegulated data types you can name in code and must never transmitOrganization-wide coverage, catching data from teams and integrations you do not control

How a trace moves through the masking layers

The trace starts in your application, where the SDK can apply client-side masking before anything leaves the process. It then reaches Langfuse Web over OTLP or SDK ingestion. With the Enterprise server-side callback enabled, Langfuse sends each OpenTelemetry trace object to your masking service before ClickHouse stores it. If the callback fails or times out, the default fail-open path stores events unmasked, while LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED=true drops them. Check that both failure paths match your data policy.

Masking layers in the ingestion path, with the callback failure branches.

How the server-side masking callback processes each trace

With server-side masking enabled, Langfuse sends each OpenTelemetry trace object to an HTTP callback that you operate, and the callback runs before the data is written to ClickHouse. Your masking logic lives in that callback, so it is the only place where sensitive fields in server-side ingestion can be redacted, replaced or dropped before storage. The callback URL is set with LANGFUSE_INGESTION_MASKING_CALLBACK_URL, and the callback must be reachable from the Langfuse Worker, which performs the processing, rather than from the browser or the application sending traces.

The default callback timeout is 500 ms, with one retry. That budget is tight, so the callback should do a fast, bounded job such as pattern-based redaction of known fields, not calls to external classifiers, large model inference or slow directory lookups. Every trace that waits on the callback adds latency to ingestion, and a callback that regularly approaches the timeout will trigger retries and, under the default setting, unmasked fallthrough. Design the callback to return quickly for the common case and keep any heavier checks out of the ingestion path.

Before you enable the callback, measure its response time at the percentiles that matter, under a load that resembles your peak ingestion, and confirm how the timeout and retry behave in your own deployment. Ask your platform team to check worker logs during the test for timeouts and retries, and confirm that a retry does not double-process traces in a way that affects your data. Re-run the test after any change to the callback's logic, its hosting or the ingestion volume, because the margin under the 500 ms budget can shrink quickly. Treat the result as the input to the fail-open or fail-closed decision covered in the next section.

Fail open or fail closed: choosing the failure behavior

When the server-side masking callback fails or times out, Langfuse has to choose between storing events unmasked and dropping them. Each option has a cost, and the four factors below determine which cost your organization can carry.

Default fail-open behavior

By default, Langfuse processes events unmasked if the masking callback fails or times out. Traces keep flowing, so developers and product teams keep their visibility, but any personal data the callback would have removed is stored in ClickHouse. Check how often your callback service is expected to be unavailable, and whether a short gap in masking is acceptable under your data classification policy for LLM traces.

Default callback timeout
500 ms
Data masking docs

Fail-closed drop setting

Setting LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED=true drops the events the callback could not process, so unmasked content never reaches storage. The cost is missing traces for the affected requests, which can leave gaps in debugging, evaluations and cost reporting. Confirm which events your evaluations depend on before enabling it, and test the drop behavior in a staging environment first.

Data loss versus personal data exposure

Fail open trades completeness of trace history for a possible exposure of personal data, while fail closed trades that exposure for missing observations. Neither option is free. Estimate the volume of traces that could pass through the callback during an outage, and ask who will explain a gap in the trace record to engineering leads and auditors if the drop setting is on.

Alignment with data classification

The right setting depends on what your prompts and outputs contain. Traces that carry health, financial or identity data usually need a different failure choice from traces that hold only product text. Map each Langfuse project to its data classification level, and document which projects accept unmasked storage during a callback failure and which do not.

Fit with the incident process

Both behaviors create events your team must handle. Fail open produces unmasked personal data that may need deletion and an incident record, while fail closed produces a loss of trace data that may need to be reported to the people who depend on it. Define alerts for callback failures, the owner who reviews them, and the steps for purging exposed data or backfilling dropped traces.

Setting up server-side masking in a self-hosted Langfuse

This sequence turns server-side ingestion masking on in a self-hosted Langfuse, with a callback you host, a tested failure behavior and evidence that sample values are redacted before they are stored.

  1. Confirm the Enterprise license key is active

    Server-side masking is an Enterprise feature, so the platform owner confirms that a valid license key is loaded in the running Langfuse instance before any other change is made. Check the key status in the instance settings and confirm the expiry date with the account owner. Done means the Langfuse UI shows the Enterprise features as enabled and a test request to the masking feature area is not blocked by a license message. Without an active key, the callback setting will have no effect.

  2. Define the fields the callback must redact

    Before writing any code, the privacy, security and application teams agree on a written list of what must never be stored in traces: for example email addresses, national identifiers, payment card numbers, patient or account identifiers, and free-text secrets. For each field, record where it appears (prompt text, model output, tool arguments, metadata) and the replacement value you want. Done means the list is signed off and every item has a sample value that the team can use in a test trace.

  3. Build and host the masking callback in your infrastructure

    The engineering team builds an HTTP endpoint that receives each OpenTelemetry trace object from Langfuse, redacts the fields from the agreed list and returns the modified object. Host it inside the same network boundary as Langfuse, with TLS, authentication between the services and no outbound calls to third-party services. The callback must respond within the default 500 ms timeout, so keep the logic simple and avoid calling slow external models. Done means the endpoint returns a redacted copy of a sample payload when called directly with curl from the Langfuse web host.

  4. Set the callback URL and failure behavior

    The operator sets LANGFUSE_INGESTION_MASKING_CALLBACK_URL to the internal address of the callback endpoint. The default timeout is 500 ms with one retry, and the callback fails open by default, which means events are stored unmasked if the callback fails or times out. To drop those events instead, set LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED to true. Record the choice and its reason in the change ticket, since fail-open favors availability of traces and fail-closed favors protection of data. Done means the variables are present in the configuration file used by both Langfuse Web and Langfuse Worker.

  5. Restart the services and confirm the configuration loaded

    The operator restarts the Langfuse Web and Langfuse Worker containers so both pick up the new environment variables, following the restart procedure of the chosen deployment method (Docker Compose, Helm or Terraform). Check the service logs for a startup message that the masking callback is configured and for no errors on the callback URL. Done means both containers are healthy and the logs show the callback is registered without startup errors.

  6. Send a test trace with a known sample value

    A tester sends a trace from a non-production project that contains a clearly fake sample value in a prompt, an output and a metadata field, for example a made-up email address in the form of a test string. Open the trace in the Langfuse UI and confirm the sample value shows the masked replacement in every place it appeared. Then query the observation tables in ClickHouse directly, using a read-only account, and search for the raw sample string. Done means the raw string is absent from the UI and from ClickHouse for all three locations, and the test is recorded with the trace identifier.

  7. Test the failure behavior with a deliberately slow callback

    In a staging environment, the tester temporarily points the callback URL at an endpoint that delays its response beyond 500 ms, or stops the callback service, and sends a trace containing the sample value. With fail-open set, the trace should be stored, and the sample value will appear unmasked, which confirms the risk the team accepted. With fail-closed set, the trace should be dropped and must not appear in the UI or ClickHouse. Done means the observed behavior matches the chosen setting, and the results are filed with the change record before the setting is promoted to production.

Which masking layer fits your deployment

An organization with an Enterprise license key can add server-side ingestion masking, which Langfuse applies before trace data is written to ClickHouse. Langfuse sends each OpenTelemetry trace object to a callback URL that you operate, and the callback returns a masked version for storage. This layer is useful when many applications, teams or SDK versions send traces and you want one central control point. It cannot guarantee that sensitive data never left the application, because by the time the server sees it, the data has already crossed the network and may sit in logs, queues or memory on the path.

  • Callback location: Confirm the callback runs inside your network, with TLS and authentication, and that its own logs do not record the raw payloads it receives.
  • Timeout and retry behavior: The default timeout is 500 ms with 1 retry, so confirm your masking service meets that under peak ingestion.
  • Fail-open or fail-closed: Decide explicitly whether unmasked events may be stored when the callback fails, and set LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED to match that decision.
  • Coverage of fields: Test that the callback masks prompts, outputs, metadata and tool arguments, not only the fields you expected.
  • Existing data: Server-side masking applies to incoming events, so confirm how historic traces already stored will be handled.

Before go-live, send synthetic personal data through each application and check what appears in the ClickHouse-backed UI and exports.

Operating the masking callback without creating a new exposure

The masking callback sees every trace object before it is stored, so it is itself a place where personal data can leak. The cards below cover the decisions and checks that keep the callback from becoming a new exposure point in your environment.

Network path and encryption

The callback receives raw OpenTelemetry trace content, including prompts and outputs that may contain personal data. Keep the callback on a network path you control, reachable only from the Langfuse Worker or Web containers, and use encryption in transit for every hop. Confirm which component calls the callback in your deployment, and confirm that the URL configured in LANGFUSE_INGESTION_MASKING_CALLBACK_URL cannot resolve to a public endpoint.

Data masking docs

No logging of unmasked payloads

A common failure is a debug log in the callback that writes the incoming trace body to stdout, a log shipper or an APM tool. Those logs can outlive the trace itself and reach people who could never read the observability data. Review the callback's logging, request and error handlers, and any framework middleware that records request bodies. Log only identifiers, sizes and masking outcomes, and test by sending a known test string and searching every log sink for it.

Callback secrets and access

The callback may hold API keys for a masking service, a detection model endpoint or a database of rules. Store those values in the secret management system your organization already uses, rotate them on your standard schedule and grant the callback's service identity only the access it needs. Keep administrative access to the callback host separate from access to the Langfuse data stores, so that no single operator can read both unmasked input and stored traces.

Callback code review and testing

The callback is a service that processes personal data, so it needs the same change control as any other such service. Require peer review of its code and rule changes, keep its dependencies patched, and build a test suite with synthetic personal data that checks each masking rule. Include tests for malformed payloads, very large traces and slow responses, because those cases decide the fail-open or fail-closed outcome.

Availability and fail-open behavior

The callback runs with a default timeout of 500 ms and 1 retry, and by default events are processed unmasked when it fails. Decide whether that default is acceptable for your data, and if not, set LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED to true and plan for dropped trace data during callback outages. Monitor callback latency and error rates, and alert on them, because a silent failure under fail-open means unmasked data is being stored.

Change and incident ownership

Name an owner for the callback who answers for its rules, its hosting and its incidents. Define how a masking gap found in production is handled, including whether affected traces are deleted, how the rule is fixed and retested, and who signs off on the change. Confirm with your security and privacy teams which records a masking incident must produce for their review.

Questions teams ask before adding Langfuse data masking

Does client-side masking in Langfuse need an Enterprise license?

No. Client-side masking happens inside your application's SDK before data is sent, and it belongs to the core feature set that Langfuse describes as available in the MIT-licensed open source version without limits. Your team can add it to a self-hosted deployment on the open source edition. The work is code in your application: identify which fields may carry personal or sensitive data, write the masking function, and test that the function runs before each trace is exported. Because it runs in your code, it is the layer that keeps sensitive data from ever leaving the application.

Does server-side ingestion masking require the Enterprise license key?

Yes. Server-side masking, where Langfuse sends each OpenTelemetry trace object to an HTTP callback before it is stored in ClickHouse, is one of the self-hosted features that needs an Enterprise license key. It is enabled with the LANGFUSE_INGESTION_MASKING_CALLBACK_URL setting. Confirm the current license terms and the key procedure in the license key documentation before you plan the rollout, since the callback is a centralized safety net that depends on the Enterprise edition being active on your instance.

What drives the effort to build a masking callback?

The effort depends on three things: the redaction rules, the data types that appear in your traces, and the testing you need before go-live. Rules that match a few well-defined identifiers are quick to write. Free-text prompts and model outputs, which can contain names, account numbers or health details in any position, need more pattern work and more review. Trace payloads also vary by framework and SDK version, so the callback must handle nested objects, attributes and attachments. Ask any partner to show how they will cover each data type and how they will prove it with test traces.

What does the work need from our side?

Four inputs make the work predictable. First, a data classification that names which fields and content types count as personal or sensitive for your organization, written by people who own that policy. Second, a test environment with a self-hosted Langfuse instance that matches production configuration, so you can replay realistic but non-production traces. Third, an owner for the callback who can approve rule changes and respond when masking fails. Fourth, access to the sample trace shapes your applications produce, so the rules match the data you actually send.

Should we choose fail-open or fail-closed for the masking callback?

The default is fail-open: if the callback fails or times out, Langfuse processes events unmasked. Setting LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED=true drops those events instead. Fail-open keeps traces flowing during an outage of the callback, but personal data may then be stored unmasked. Fail-closed protects stored data at the cost of lost observability during failures. Many teams decide per data class: they fail closed for regulated content and fail open for low-risk operational traces. Record the decision, the owner who accepts the loss of visibility, and the alerting that tells you when the callback is failing.

Can our own engineers build and run this without a partner?

Often yes, if you have engineers who know your trace payloads and can write and test the rules. The work is bounded: a client-side function in your applications, a small HTTP service for the callback with a 500 ms default timeout and one retry, the Enterprise key, and tests. The harder parts are coverage testing across data types, operating the callback as a production service with monitoring, and keeping rules current as prompts and tools change. If those skills are thin in your team, a fixed-scope engagement can cover the build and hand over documentation and runbooks.

What should a written quote for masking include?

A written quote should list the scope in concrete terms: which applications and SDKs receive client-side masking, which trace types the server-side callback covers, and which data classes the rules address. It should name the deliverables, such as the masking code, the callback service, test cases, the fail-open or fail-closed configuration, monitoring and a runbook. It should state the client inputs it depends on, the test environment, the acceptance criteria, and what happens if the classification changes mid-project. Ask how cost is split between one-time build and any recurring rule maintenance, and whether an Enterprise license is required on your side.

Limits to confirm in your environment before you rely on masking

Server-side masking only protects what the callback can see, and it acts on data at the point of ingestion. The cards below cover the gaps that most often surprise teams, from coverage and failure behavior to stored data and version status. Confirm each point against the Langfuse docs and with your own tests before treating masking as a control.

Field coverage of the callback

The masking callback only receives the OpenTelemetry trace objects that Langfuse sends to it, so any field your application writes outside those objects is never inspected. Map every place personal data can appear in a trace, including prompts, completions, tool inputs, metadata and attachments, and confirm each one is present in the payload your callback receives. Run a test trace with known sample values in every field and check the stored result in the UI and API.

Data masking docs

Fail-open default behavior

By default the callback fails open, so if it errors or times out, Langfuse stores events unmasked. Setting LANGFUSE_INGESTION_MASKING_CALLBACK_FAIL_CLOSED to true drops those events instead, which protects data but can lose trace history during an outage. Decide which outcome your privacy team accepts, then test an outage on purpose and confirm that alerts fire when it happens.

Stored data is not changed

Masking applies to events as they are ingested, so traces already in ClickHouse keep their original values. If personal data was stored before masking was enabled, you need a separate remediation step, such as deleting or re-ingesting affected traces under your retention and deletion process. Confirm with a test that masking only changes new ingestion and document how you will handle the historical data.

Callback latency against the timeout

The default callback timeout is 500 ms with one retry, and every ingested event waits on the callback. If your masking service runs slower under load, it will trip the timeout and either leak data or drop events depending on your fail mode. Measure the callback's p95 and p99 latency at expected ingestion volume and confirm that the timeout and retry settings leave margin for it.

Langfuse version and license status

Server-side masking requires an Enterprise license key, and the feature depends on the Langfuse version you run. Confirm that your key is active in the deployed instance, that the version includes the masking callback, and that your upgrade plan keeps the setting working. Check the release notes before each upgrade so a change does not silently disable masking.

License key docs

Client-side masking as the first layer

Because server-side masking is a central safety net and not a replacement for client-side masking, data that must never leave the application should be masked in the SDK before it is sent. Verify that the client masking function runs in every service, language and framework that sends traces, including background jobs. Test each path with sample personal data and confirm nothing reaches Langfuse unmasked.

How DeployOpen scopes and delivers Langfuse masking

DeployOpen plans Langfuse data masking as part of the wider self-hosted deployment, so client-side SDK rules, any server-side ingestion callback and the fail-open or fail-closed choice are decided together. Each engagement is fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory which prompts, outputs, metadata and attachments reach traces, and which fields must never leave the application.
  • Record the data classes, owners and the masking rules each team has agreed to before any code changes.
  • Decide in writing whether server-side ingestion masking is needed, and whether an Enterprise license key is in scope.

How we build

  • Implement client-side masking in the application SDK so sensitive values are removed before they are sent to Langfuse.
  • Where the Enterprise license applies, deploy the ingestion masking callback, set its URL, timeout and retry values, and test it.
  • Test the fail-open and fail-closed settings against forced callback failures and timeouts, then record the chosen behavior.

How we hand over

  • Document the masking rules, callback design, configuration keys and the reasoning behind the fail-open or fail-closed setting.
  • Provide test cases and evidence showing that masked fields do not appear in stored traces, so your security and compliance teams can review them.
  • Walk your engineering and operations teams through the runbook, including what to do when the masking callback is unavailable.

How we support

  • Support changes to masking rules as applications, prompts and data types change, under a written scope.
  • Retest masking after Langfuse upgrades or callback changes, since upgrades follow their own migration guides.
  • Ongoing support, upgrades and continuous testing are available as a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.