Skip to main content
Each trace you run is usually connected to entities in your own application - things like user_id, chat_id, or anything else that is tied to the flow that triggered the trace. OpenLLMetry allows you to easily mark traces with these IDs so you can track them in the UI.
You can use any key-value pair to associate a trace with an entity - it can also be org_id, team_id, whatever you want. The only requirement is that the key and the value are strings.
from traceloop.sdk import Traceloop
 
Traceloop.set_association_properties({ "user_id": "user12345", "chat_id": "chat12345" })
// Option 1 (for class methods only) - set association properties within a workflow, task, agent or tool
class MyClass {
  @traceloop.workflow({ associationProperties: { userId: "user123" })
  myMethod() {
    // Your code here
  }
}

// Option 2 - set association properties within a workflow, task, agent or tool
traceloop.withWorkflow(
  {
    name: "workflow_name",
    associationProperties: { userId: "user12345", chatId: "chat12345" },
  },
  () => {
    // Your code here
    // (function can be made async if needed)
  }
);

// Option 3  - set association properties directly
traceloop.withAssociationProperties(
  {
    userId: "user12345",
    chatId: "chat12345",
  },
  () => {
    // Your code here
    // (can be async or sync)
  }
);