This page describes attributes for functions traced with the
@weave.op decorator. If you instrument an agent with the Weave agent SDK, set attributes and events on agent spans (Turn, LLM, Tool, and SubAgent) instead. See Set attributes and events on agent spans.- Deployments
- Tenants
- Experiments
- Per-call attributes: Use the
weave.attributes()context manager to add metadata to specific operations or code blocks. - Global attributes: Use the
global_attributesfield to set attributes at initialization that apply to all traces and evaluations in your project.
Per-call attributes
Theweave.attributes() context manager lets you add metadata to specific traced operations. Use it to tag particular function calls or evaluation runs with contextual information.
weave.attributes() contexts. Inner contexts override outer contexts for the same keys:
Global attributes
When you set global attributes during Weave initialization, they automatically apply to all traces and evaluations in your project. This is useful for propagating project-wide metadata like environment, deployment version, or team information.Combine global and per-call attributes
You can use global attributes and per-call attributes together. Per-call attributes with the same key override global attributes:Get attributes during execution
At runtime, you can inspect the attributes in effect for a Call. This is useful when you want to debug which metadata Weave attaches, or when your code needs to branch on contextual information set by an outer caller.- Python
- TypeScript
The following example sets the Weave decorator to log the This outputs:
process_data function, configures attributes to log, and then returns them on execution.weave.get_current_call() only works inside a @weave.op decorated function. Outside of an op, it returns None.