Separating production and staging in Langfuse with environments
Environments in Langfuse are the label that tells one stage's traces, observations and scores apart from another's. When one self-hosted Langfuse receives data from production, staging and development, each trace should carry its environment so dashboards, score reviews and prompt checks can be filtered to the stage you mean. Without that, a staging experiment can skew production latency charts, a development evaluation run can sit beside real user scores, and a prompt tested in staging can be read as the production version. The environment is the main control for keeping those views clean inside a single project.
Environments are created the first time data arrives with a given value, so no separate setup step is needed in the UI. They persist after creation, and according to the Langfuse environments documentation, they cannot currently be deleted or renamed in the UI. Traces that arrive without an explicit value are placed in the default environment. Before you choose names such as production and staging, agree them across every team and service, because a misspelled value creates a new environment that you cannot remove from the interface. Confirm with your Langfuse version whether any API route exists for cleanup, and plan naming conventions before the first deployment reaches production.
The environment is set with the LANGFUSE_TRACING_ENVIRONMENT variable, or with the client environment parameter, and the client parameter takes precedence. Decide where each value is set: in deployment configuration for each stage, or in code for services that span stages. Check in staging that a test trace lands in the expected environment, and check that the default environment is not receiving production traffic from a service that was missed in the rollout.
Which setting to use to label each stage
This table compares the deployment-level LANGFUSE_TRACING_ENVIRONMENT variable with the environment parameter set in client code, and shows which one applies in common service layouts. The client parameter takes precedence when both are set, so read each row as the setting that wins for that layout.
| Setting | Where it is set | Precedence and default | When it fits |
|---|---|---|---|
| LANGFUSE_TRACING_ENVIRONMENT | Deployment configuration for one running service, such as a container environment variable | Used when the client does not pass its own environment value. Falls back to default if neither is set | One service per stage, where each stage has its own deployment configuration |
| Client environment parameter | Code passed to the Langfuse SDK when the client is initialized | Takes precedence over LANGFUSE_TRACING_ENVIRONMENT when both are set | Several services or workers in the same stage that need distinct labels, or when code runs in more than one stage |
| Both set together | Variable in deployment and parameter in code | The code parameter wins for that client. Confirm the value in a test trace | Use only when a default is needed for most code and explicit overrides for specific components |
| Neither set | No configuration for the environment | Traces are recorded under the value default | Local experiments only. Avoid in shared projects, because stages become hard to separate |
| Shared library | Library code that does not own its deployment | Should not hardcode a stage. Relies on the calling service to set the value or on the deployment variable | Common helper packages used by several services. Confirm each consuming service sets a value before release |
Setting up environments in a self-hosted Langfuse
This sequence gives each stage its own environment value in Langfuse, so production, staging and development traces stay separate and filterable within one project. Each step ends with a check that confirms the setting took effect before the next stage is configured.
Agree the environment naming scheme
The platform team and the application owners agree on one exact string for each stage, such as production, staging and development, and write them into a shared configuration standard. Use lowercase, short names with no spaces, and confirm that every team uses the same spelling because values are case-sensitive in practice and cannot be renamed later in the UI. Done means a written list of approved values that every team has signed off, with no stage left to a free-text choice.
Set the environment in each stage configuration
Each application team sets the LANGFUSE_TRACING_ENVIRONMENT variable in the configuration for its stage, or passes the environment parameter in the SDK client. Where both are present, the client parameter takes precedence, so the team should check which one its code path actually uses and avoid setting two different values. Done means each deployment's configuration file or secret store shows exactly one approved value for that stage, reviewed in the same change that deploys the application.
Confirm the setting in the running application
Before sending any traces, the team reads the effective configuration inside the running container or process, for example by logging the resolved value at startup. This catches cases where a secret did not load, a template variable was empty, or an override in code replaced the intended value. Done means the logged value matches the approved name for that stage in every environment where the application runs.
Send a test trace from each stage
Each team sends one simple test trace from its staging or development deployment, and the platform team does the same for production using a non-sensitive test request. Keep the test payload free of personal data and label it clearly so it can be identified later. Done means one test trace per stage has arrived in the Langfuse project and is visible in the trace list.
Check the environment filter in the project
An administrator opens the project in the Langfuse UI and confirms that each stage's value appears as an environment option in the filter, with the test trace under the correct value. If a test trace appears under another name, or under default, return to the configuration step and find the source of the mismatch before going further. Done means every approved environment appears, and each test trace is found only under its own stage.
Check that no stage falls back to default
The team looks for traces under the default environment that came from a configured stage, which indicates that the variable was not read. Because Langfuse uses default when no environment is set, this check should be repeated after each deployment, not only at launch. Done means no traces from a configured application appear under default, and the team records the check in its deployment runbook.
Record the environment names as permanent
Because environments are persistent and cannot currently be deleted or renamed in the UI, the team records the approved list with its owners and adds a review step to any change that introduces a new environment value. Ask your Langfuse administrator to confirm the current behavior for your version before relying on it, since a mistyped value stays in the project's environment list. Done means the approved names are stored with the platform documentation and every new value goes through the same review.
How stage traces reach one project and split by environment
The diagram starts with development, staging and production applications, each setting its own environment value through LANGFUSE_TRACING_ENVIRONMENT or the client parameter, which takes precedence. Traces travel over the SDK or OTLP path to the self-hosted Langfuse Web container, then the Worker processes the events into the one project's stores. The check to make is that every view, filter and export in the project is scoped to the environment you expect, because the data lands together in the same project.
Three applications send tagged traces into one self-hosted project, split at query time.
When separate projects are the better boundary
Use one Langfuse project per environment only when the difference is about who may see or change data, not just which build produced it. Environments label traces, observations and scores, but every member with access to the project can still see all of them. If a team or customer must never see another's traces, or if production traces must be isolated from experimentation by access rules rather than by a filter, a shared project with an environment value is the wrong boundary. In that case, split into separate projects, each with its own API keys and its own role assignments.
Project-level controls are configured per project, so they cannot be set differently for production and staging inside one project. Retention windows are the clearest example: if production traces must be kept longer than experimental staging data, or a regulator or customer contract sets a window for one dataset only, a separate project lets you apply a distinct retention policy without touching the other. Project-level RBAC roles work the same way, so a contractor who needs to review staging traces can hold a Viewer role on that project without any path to production. Confirm with your organization's counsel and your license terms whether these controls need an Enterprise license key, because project roles and retention policies are on the list of features that do. Also check how your existing API key and role model maps onto project boundaries before you commit.
Before you split, weigh the cost. Each project needs its own prompts, datasets, evaluators and dashboards, so reuse across environments becomes a copy or export task. Cross-environment comparisons, such as a staging experiment against production traces, are harder when the data sits in two projects. A practical test is to ask whether the boundary would still matter if every person in the organization could read everything. If the answer is no, keep one project and rely on environment filters. If the answer is yes, separate projects, and plan the prompt and dataset sync process before go-live.
Access and data risks of mixing stages in one project
Environments label data, but they do not separate it. Every user, prompt, label, retention setting and score in a shared project is visible to anyone whose role covers that project, so each risk below depends on a control you set in the project or on a practice your team follows.
Staging users seeing production traces
A developer with project access can open the trace list and see production traces unless every view is filtered to production. Traces can contain customer prompts and model outputs, so the exposure is about who holds a role in the project, not only which environment they browse. Check which roles in the project are allowed to read production data, and confirm that staging testers hold only the access they need. Project-level roles are an Enterprise feature in self-hosted Langfuse, so confirm your license before you rely on them.
Mislabeled traces polluting production
A service that sends traces with no LANGFUSE_TRACING_ENVIRONMENT set falls back to default, and a misconfigured staging deployment can send data under production. Either way, cost and quality dashboards quietly absorb test traffic. Set the variable in every deployment manifest, and check that each service reports the value you expect before it reaches production. Review traces that land under default as a sign of a missing setting.
Staging prompt versions reaching production
Prompt labels are shared across the project, so a version promoted to a production label in a test workflow can be fetched by live applications within minutes of the change. Protected prompt labels, which need an Enterprise license key, limit who can move a label. Without them, define a release step in which only reviewed versions receive the production label, and record who made each move.
Retention applied to all stages at once
Retention policies in self-hosted Langfuse are set per project, so one window covers development, staging and production traces alike. A short window suited to test noise can delete production data that your own retention schedule requires you to keep, and a long window keeps throwaway test data longer than needed. Confirm the retention period with your compliance owner, and decide whether stage-specific data needs its own project to get a different window.
Evaluation scores mixed across stages
Scores from LLM-as-a-judge runs, human annotation and user feedback are stored with the traces they judge. If staging evaluations run on the same model or dataset as production, their averages blend into production quality metrics and can hide a regression. Filter score views by environment before you compare releases, and keep experiment datasets labeled by the stage that produced them.
Environment names that cannot be removed
Environments are created the first time data arrives with a given value, and they cannot currently be deleted or renamed in the UI. A typo such as prod- or Production stays in the filter list permanently and invites mistakes. Agree the names in a written standard, and test them in a non-production deployment before any production service uses them.
Questions teams ask before separating environments
Do environments in Langfuse cost extra?
Using environments does not require a separate plan or license: the environment is a tag set through LANGFUSE_TRACING_ENVIRONMENT or the client environment parameter, and the open source version includes core features without limits. Costs come from what runs around it. Your team pays for the Langfuse infrastructure, which holds the same data whether it is tagged production or staging, so extra stages add storage and ingestion. If you want enterprise features such as role-based access control on projects, check the license terms on the Langfuse self-hosted pricing page and the license key docs before you commit, since those plans are priced by Langfuse and not published here. Ask your partner or internal team to confirm which features your design depends on.
How long does environment setup take, and what drives it?
Setup time depends mostly on how many applications send traces and how many of them already tag data. Setting the variable in a single service is a short change; standardizing it across every service, pipeline and notebook takes longer because each one needs its own configuration review and deployment. The naming scheme, the number of stages you need to separate, and whether any application is instrumented through OpenTelemetry instead of a Langfuse SDK also change the work. Ask any partner for a written scope that lists each application, the stages covered and the verification steps, since those items determine the schedule.
Can an in-house team set up environments alone?
Yes, for a small number of applications, an in-house team can set the variable, agree on names and verify the result without outside help. The work is mostly configuration and review, not new code. It becomes harder when many teams run services with different deployment tooling, when traces arrive through several SDKs or OpenTelemetry pipelines, or when the same team must also run the Langfuse platform itself. Decide early who owns the naming standard, who reviews changes to it and who checks the dashboards after each release.
What does the work need from our team?
Your team needs to supply three things. First, a naming standard that fixes the exact environment values, such as production, staging and development, and bans ad hoc names. Second, test traces from every application and every stage, so you can confirm that each one lands in the right environment and that the filters in the UI show it. Third, an access review that lists who can view traces from each stage, because environment filters organize data but do not restrict who can see it. Most delays come from missing owners for these three items, not from the configuration itself.
Should we use one Langfuse project or several for each stage?
Keep one project when production and staging share prompts, datasets and evaluators, because environments let you filter one set of resources without copying them. Use separate projects when stages need different access rules, different retention windows or strict isolation for regulated data, since project-level roles and retention settings apply per project. Note that environments cannot currently be deleted or renamed in the UI, so a naming mistake persists. Write the decision down with the reason, because moving data between projects later is more work than choosing correctly now.
How do we fix traces tagged with the wrong stage?
Stop the wrong value at the source first: correct the LANGFUSE_TRACING_ENVIRONMENT setting or the client environment parameter, since that setting takes precedence and the environment is created the first time data arrives with a given value. Old traces stay under the wrong name because environments are persistent and cannot currently be deleted or renamed in the UI. Filter views by environment so the stray data does not distort dashboards, and record the bad value in your naming standard so no one reuses it. If the mislabeled data matters for audit or evaluation, confirm with your Langfuse operator how to handle it before any bulk change.
How DeployOpen scopes environment and tenancy design
DeployOpen scopes environment design as a written part of a fixed-scope Langfuse deployment or review. Before any build starts, the scope agrees the environment naming standard (for example, which values teams send for development, staging and production), which Langfuse organizations and projects hold each stage, and which stages share a project. Because Langfuse creates an environment the first time data arrives with a given value and cannot currently delete or rename it in the UI, a naming mistake persists in the data. The agreed standard therefore gets written down and checked before any application sends traces.
Configuration and testing are then done stage by stage. Each deployment sets LANGFUSE_TRACING_ENVIRONMENT or the client environment parameter, which takes precedence, and the team confirms that traces from a test run land under the right value and that the default environment default does not receive stray production traffic. Views, dashboards and exports are checked for an environment filter, and shared prompt labels and datasets are tested to confirm that a staging change cannot overwrite what production reads. Confirm with your own team which prompts and datasets must be shared and which must stay separate, since that decision decides whether one project is enough.
The decisions are recorded in a design document that your compliance and security teams can review, covering the naming standard, project boundaries, role assignments and the reasons for each choice. Ongoing changes, such as adding a new stage, upgrading Langfuse or reviewing access, can be handled under a retainer for ongoing support and testing. Ask any provider to show how they will document the environment decision and what happens to existing data if a naming standard changes.

