How Environments Work
1
Set environment via environment variable or SDK
Configure the environment using the
ABV_TRACING_ENVIRONMENT environment variable (recommended) or the environment parameter during client initialization. Common values: production, staging, development, dev..env
2
All events tagged with environment
Once configured, every trace, observation (span/event/generation), score, and session automatically includes the environment attribute. This happens transparently without code changes.
3
Filter by environment in the ABV UI
Use the environment filter in the ABV dashboard navigation bar to switch between environments. The filter applies across all views, showing only events from the selected environment.
4
Analyze metrics by environment
Compare performance, costs, and error rates between environments. Identify staging vs production differences. Track environment-specific trends over time.
5
Reuse prompts and datasets across environments
Create prompts in staging, test them thoroughly, then use the same prompts in production. Share datasets between environments while keeping traces separate.
Why Use Environments?
Separate Production from Development
Separate Production from Development
The Challenge: Your team has 10 developers running code locally, 3 staging deployments for different features, and 1 production deployment. All traces flow into the same ABV project, creating chaos in your dashboard.The Solution: Set environment variables per deployment context.Locally (.env.local):Staging (Kubernetes/Docker):Production (Kubernetes/Docker):The Result: Production dashboard shows only real user traffic. Developers can experiment freely in
dev without polluting production data. Staging provides a clean pre-production testing ground.Operational benefit: On-call engineers filter to production and see only what matters. No false alarms from dev experiments or staging tests.Staged Rollouts & Safe Testing
Staged Rollouts & Safe Testing
The Challenge: Youβre deploying a new RAG implementation that changes how documents are chunked. It might improve accuracy or it might break everything. You need to validate before exposing to customers.The Solution: Deploy the change to staging first with environment separation.The Result:
- Deploy to staging, generate traces tagged
staging - Analyze staging performance, accuracy, cost
- Compare staging metrics to production baseline
- If good, deploy to production with confidence
- If issues found, fix in staging first
Debugging with Full Context
Debugging with Full Context
The Challenge: Customer support forwards a bug report: βThe LLM isnβt working.β You need to know: Is this production? Staging? Someoneβs local dev environment? Without context, you canβt prioritize or debug effectively.The Solution: Every trace includes environment information, visible in the UI and queryable via API.The Result:
- See
environment: productionβ drop everything, production is down - See
environment: stagingβ important but not urgent, investigate during business hours - See
environment: devβ probably a developer debugging, low priority
Cost Attribution by Environment
Cost Attribution by Environment
Filter cost dashboards by environment to identify spending on non-production workloads.Example breakdown:
- Production: 70% (real customer value)
- Staging: 25% (integration tests, load tests)
- Dev: 5% (developer experiments)
Compliance & Audit Trails
Compliance & Audit Trails
The Challenge: Your compliance team asks: βCan you prove that customer PII is only processed in production, never in development?β Without environment separation, this is nearly impossible to demonstrate.The Solution: Use environments to create clear separation boundaries.The Result: Audit logs show PII traces exist only in
production environment. Development and staging use synthetic data only. Clear compliance demonstration.Bonus: Combine with RBAC to restrict who can view production traces containing sensitive data.Shared Resources Across Environments
Shared Resources Across Environments
Implementation Guide
Python SDK
Python SDK
- Environment Variable (Recommended)
- Client Initialization Parameter
The simplest and most common approach:Create a Load and use in your code:Why this approach:
.env file:.env
- Environment variables are deployment-best-practice
- No code changes needed between dev/staging/prod
- Works with Docker, Kubernetes, serverless platforms
- Prevents accidentally hardcoding wrong environment
- Must match regex:
^(?!abv)[a-z0-9-_]+$ - Cannot start with βabvβ
- Only lowercase letters, numbers, hyphens, underscores
- Maximum 40 characters
- Examples:
production,staging,dev,local,qa-team-1
JavaScript/TypeScript SDK
JavaScript/TypeScript SDK
- Environment Variable (Recommended)
- Different Environments
Create a Create Import at the top of your application:
.env file:.env
instrumentation.ts:instrumentation.ts
index.ts
OpenTelemetry
OpenTelemetry
When using OpenTelemetry directly, ABV recognizes these attributes for environment:See OpenTelemetry Integration for more details.
abv.environment(recommended)deployment.environment.namedeployment.environment
- Resource Attributes (Global)
- Per-Span Attributes
- Alternative Attributes
Set environment globally for all spans using resource attributes:
Filtering & Analysis
UI Filtering
In the ABV dashboard, use the environment filter in the navigation bar to switch between environments. The filter applies across:- Traces list
- Sessions view
- Scores and evaluations
- Custom dashboards
- Analytics and metrics
API Filtering
Filter by environment when querying the ABV API:Best Practices
Default environment: If no environment is specified, ABV uses
default as the environment name. Explicitly set environments even in development to avoid mixing default data from different contexts.Environments vs Tags vs Metadata
Choosing the right feature:
When to use together:
- Set environment to
productionAND use tags likebetafor gradual feature rollouts - Set environment to
stagingAND use metadata for detailed test scenario tracking - All traces should have an environment, most will have metadata, many will have tags
Related Features
Tags
Add simple string labels for flexible categorization and filtering
Metadata
Attach structured key-value data for detailed analytics and querying
Role-Based Access Control
Control who can view and modify production data with granular permissions
Data Retention
Configure different retention policies for production vs staging data