Metadata
Attach additional information like reward scores, customer IDs, tags, and other relevant data to your traces.
Metadata Options
Use the tracer set_customer_id
method to associate traces with specific users or organizations for filtering, analytics, and cost tracking purposes.
from judgeval.tracer import Tracer
judgment = Tracer(project_name="my-project")
# Set customer ID for multi-tenant app
judgment.set_customer_id("customer_12345")
# OR
# Use with user authentication
def handle_request(user_id):
judgment.set_customer_id(user_id)
# ... process request
Use the set_tags
method to categorize and filter traces by environment, feature, or workflow type.
# Environment and feature tags
judgment.set_tags(["production"])
# A/B testing
judgment.set_tags(["beta-feature"])
Use the update_metadata
method for any miscellanious information you want to track with your traces.
# Track business metrics
judgment.update_metadata({
"user_satisfaction": 4.5,
"conversion_rate": 0.12,
"feature_flags": ["new_ui", "beta_model"]
})
# Track A/B test information
judgment.update_metadata({
"experiment_id": "exp_123",
"variant": "treatment_a",
"cohort": "power_users"
})
Using Trace Metadata
When you call any of the metadata functions (e.g., judgment.set_customer_id()
, judgment.set_tags()
, or judgment.update_metadata()
) and export your traces, the metadata will be included in the JSON output.
In this example, we called judgment.set_reward_score(0.95)
:
[
{
"trace_id": "3484ecbd-24df-4a9f-8865-c2db25aacfe1",
"metadata": {
"reward_score": 0.95
},
"trace_spans": {
// agent trace trajectory stored here
},
// other Trace fields here
}
]
Trace metadata can also be viewed in the Judgment platform's monitoring page (seen here with tags):