Basic Features
Environments
5 min
environments allow you to organize your traces, observations, and scores from different contexts such as production, staging, or development this helps you keep your development and production data separate while using the same project filter and analyze data by environment reuse datasets and prompts across environments you can configure the environment by setting the abv tracing environment environment variable (recommended) or by using the environment parameter in the client initialization if both are specified, the initialization parameter takes precedence if nothing is specified, the default environment is default data model the environment attribute is available on all events in abv traces observations (spans, events, generations) scores sessions see data model https //docs abv dev/observability data model for more details the environment must be a string that follows this regex pattern ^(?!abv)\[a z0 9 ]+$ with at most 40 characters this means cannot start with “abv” can only contain lowercase letters, numbers, hyphens, and underscores usage python sdk from abvdev import get client, observe import os \# set the environment variable \# alternatively, set via env file and load via dotenv os environ\["abv tracing environment"] = "production" \# get the client (will use environment variable) abv = get client() \# all operations will now be associated with the "production" environment with abv start as current span(name="my operation") as span \# your code here pass @observe def main() return "hello" main() js/ts sdk set the abv environment via environment variable abv tracing environment="production" opentelemetry when using opentelemetry , you can set the environment using any of these attributes abv environment deployment environment name deployment environment to set an environment property globally, you can use resource attributes os environ\["otel resource attributes"] = " abv environment =staging" alternatively, you can set the environment on a per span basis from opentelemetry import trace from opentelemetry trace import status, statuscode tracer = trace get tracer( name ) with tracer start as current span("my operation") as span \# set environment using abv specific attribute span set attribute("abv environment", "staging") \# or using opentelemetry convention span set attribute("deployment environment name", "staging") filtering in the abv ui, you can filter events by environment using the environment filter in the navigation bar this filter applies across all views in abv see our api reference https //docs abv dev/public api for details on how to filter by environment on our api