Metadata
Attach custom key/value tags to runs and spans so you can filter and break them down later.
Metadata is free-form key/value data you attach to a run or a span. Unlike user properties, which live on the user, metadata describes a single execution: the tenant, the environment, a feature flag, a request ID. It's filterable and breakdownable in the dashboard.

Run metadata
Pass what you know when the run starts as the metadata option, and add what you learn later with setMetadata:
await trodo.wrapAgent('support-agent', async (run) => {
const route = await router.pick(question);
run.setMetadata({ route });
// ...
}, { distinctId: user.id, metadata: { tenant: 'acme', env: 'prod', release: process.env.GIT_SHA } });with trodo.wrap_agent("support-agent", distinct_id=user.id,
metadata={"tenant": "acme", "env": "prod"}) as run:
route = router.pick(question)
run.set_metadata({"route": route})
...startRun and endRun take metadata too. Over OTLP, set trodo.metadata.<key> attributes (OpenTelemetry).
Span attributes
Attach key/value pairs to a single span with setAttribute / set_attribute. They show in the span detail and are searchable.
await trodo.withSpan('billing.lookup', async (span) => {
span.setTool('billing.lookup');
span.setAttribute('customer_tier', 'enterprise');
span.setAttribute('region', 'eu-west-1');
return await billing.lookup(id);
}, { kind: 'tool' });with trodo.span('billing.lookup', kind='tool') as span:
span.set_attribute('customer_tier', 'enterprise')
span.set_attribute('region', 'eu-west-1')
result = billing.lookup(id)Run metadata vs. span attributes
| Kind | Set with | Scope |
|---|---|---|
| Run metadata | setMetadata / set_metadata | The whole run |
| Span attribute | setAttribute / set_attribute | One step inside the run |
Keep values to short strings, numbers and booleans (tenant, region, release, a flag) so they filter and group cleanly in Traces, evals and alerts.