How to associate traces with entities in your own application
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 TraceloopTraceloop.set_association_properties({ "user_id": "user12345", "chat_id": "chat12345" })
// Option 1 (for class methods only) - set association properties within a workflow, task, agent or toolclass MyClass { @traceloop.workflow({ associationProperties: { userId: "user123" }) myMethod() { // Your code here }}// Option 2 - set association properties within a workflow, task, agent or tooltraceloop.withWorkflow( { name: "workflow_name", associationProperties: { userId: "user12345", chatId: "chat12345" }, }, () => { // Your code here // (function can be made async if needed) });// Option 3 - set association properties directlytraceloop.withAssociationProperties( { userId: "user12345", chatId: "chat12345", }, () => { // Your code here // (can be async or sync) });
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"traceloop","colors":{"primary":"#EAB308","light":"#EAB308","dark":"#EAB308"},"favicon":"https://mintcdn.com/enrolla/-xQ9K52hAYrcQGvz/favicon.png?fit=max\u0026auto=format\u0026n=-xQ9K52hAYrcQGvz\u0026q=85\u0026s=6066426161fe311654d19ebca89ee7c0","logo":{"light":"https://mintcdn.com/enrolla/GspX1ocwd1gETLy0/logo/traceloop-light.png?fit=max\u0026auto=format\u0026n=GspX1ocwd1gETLy0\u0026q=85\u0026s=e245f77b5b8af11ef9aa4a0ce2ee97a6","dark":"https://mintcdn.com/enrolla/GspX1ocwd1gETLy0/logo/traceloop-dark.png?fit=max\u0026auto=format\u0026n=GspX1ocwd1gETLy0\u0026q=85\u0026s=d34d3b622526506a2a4512b32d4ebb9b"},"api":{"openapi":"openapi.json","mdx":{"server":"https://app.traceloop.com/api","auth":{"method":"bearer","name":null}}},"appearance":{"default":"dark","strict":null},"background":{"decoration":null,"color":{"light":null,"dark":"#09090B"}},"navbar":{"links":[{"label":"Community","href":"https://traceloop.com/slack"},{"label":"Support","href":"https://support.traceloop.com"}],"primary":{"type":"button","label":"Start now","href":"https://app.traceloop.com/"}},"footer":{"socials":{"github":"https://github.com/traceloop","twitter":"https://twitter.com/traceloopdev"}},"integrations":{"gtm":{"tagId":"GTM-NDQVZMH"}},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"enrolla","hasAudioNarration":false,"actualSubdomain":"enrolla","customDomains":["www.traceloop.com"],"gitSource":{"type":"github","owner":"traceloop","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae91415bf5fde76d1e17a22:success","clientVersion":"0.0.4087","searchFilterCounts":[{"language":"default","tag":"Dashboard API","count":55},{"language":"default","tag":"OpenLLMetry","count":55},{"language":"default","tag":"Evaluators","count":43},{"language":"default","tag":"Integrations","count":34},{"language":"default","tag":"Documentation","count":30},{"language":"default","tag":"Tracing","count":14},{"language":"default","tag":"Quick Start","count":9},{"language":"default","tag":"Auto-monitor-setups","count":6},{"language":"default","tag":"Playgrounds","count":4},{"language":"default","tag":"Self-host","count":4}]},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#topbar-cta-button span,#topbar-cta-button svg{color:#09090B!important}#topbar-cta-button span.absolute{border-radius:8px!important}.nav-logo{width:140px!important}"}],"page":{"pagePath":"openllmetry/tracing/association","slug":"/openllmetry/tracing/association","pageMetadata":{"title":"Associating Entities with Traces","description":"How to associate traces with entities in your own application","href":"/openllmetry/tracing/association"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How to associate traces with entities in your own application\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Each trace you run is usually connected to entities in your own application -\nthings like `,_jsx(_components.code,{children:`user_id`}),`, `,_jsx(_components.code,{children:`chat_id`}),`, or anything else that is tied to the flow that triggered the trace.`]}),`\n`,_jsx(_components.p,{children:`OpenLLMetry allows you to easily mark traces with these IDs so you can track them in the UI.`}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`You can use any key-value pair to associate a trace with an entity - it can\nalso be `,_jsx(_components.code,{children:`org_id`}),`, `,_jsx(_components.code,{children:`team_id`}),`, whatever you want. The only requirement is that\nthe key and the value are strings.`]})}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Python`,numberOfLines:`3`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` traceloop.sdk `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Traceloop`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`Traceloop.set_association_properties({ `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user12345\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat12345\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Typescript`,numberOfLines:`31`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`31`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Option 1 (for class methods only) - set association properties within a workflow, task, agent or tool`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` MyClass`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` @`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`traceloop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`workflow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`associationProperties:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`userId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user123\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` myMethod`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Your code here`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Option 2 - set association properties within a workflow, task, agent or tool`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`traceloop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`withWorkflow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"workflow_name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` associationProperties:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`userId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user12345\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chatId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"chat12345\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Your code here`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // (function can be made async if needed)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Option 3 - set association properties directly`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`traceloop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`withAssociationProperties`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` userId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user12345\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` chatId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"chat12345\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Your code here`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // (can be async or sync)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Associating Entities with Traces","description":"How to associate traces with entities in your own application","href":"/openllmetry/tracing/association"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":["/docs/_mintlify/custom/enrolla/99d79fc3a15df79c/vibekit.js","/docs/_mintlify/custom/enrolla/a052f9c2fb91f2bb/scripts/filter-openapi.js","/docs/_mintlify/custom/enrolla/f023a04dbd14c606/scripts/update-mint-navigation.js"],"subdomain":"enrolla","siteName":"traceloop","title":"Associating Entities with Traces - traceloop","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-25T08:51:17.458Z","originalFileLocation":"openllmetry/tracing/association.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How to associate traces with entities in your own application\">\u003cmeta data-mint-head name=\"application-name\" content=\"traceloop\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Associating Entities with Traces - traceloop\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to associate traces with entities in your own application\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"traceloop\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.traceloop.com/docs/openllmetry/tracing/association\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://enrolla.mintlify.site/docs/_mintlify/api/og/v2?division=Tracing\u0026amp;title=Associating+Entities+with+Traces\u0026amp;description=How+to+associate+traces+with+entities+in+your+own+application\u0026amp;theme=ff62921debafe09ea1aaaffe\u0026amp;signature=e5ec790b1633fa4f386e31c4ec1168c296e42ae5370de632f31fb131b054a7cb\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Associating Entities with Traces - traceloop\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to associate traces with entities in your own application\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://enrolla.mintlify.site/docs/_mintlify/api/og/v2?division=Tracing\u0026amp;title=Associating+Entities+with+Traces\u0026amp;description=How+to+associate+traces+with+entities+in+your+own+application\u0026amp;theme=ff62921debafe09ea1aaaffe\u0026amp;signature=e5ec790b1633fa4f386e31c4ec1168c296e42ae5370de632f31fb131b054a7cb\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/enrolla/c4jFPLhIQoqlp6LG/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"traceloop\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#EAB308\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.traceloop.com/docs/openllmetry/tracing/association\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/openllmetry/tracing/association.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.traceloop.com/#organization\",\"name\":\"traceloop\",\"url\":\"https://www.traceloop.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/enrolla/GspX1ocwd1gETLy0/logo/traceloop-light.png?fit=max\u0026auto=format\u0026n=GspX1ocwd1gETLy0\u0026q=85\u0026s=e245f77b5b8af11ef9aa4a0ce2ee97a6\"}},{\"@type\":\"WebSite\",\"@id\":\"https://www.traceloop.com/docs#website\",\"name\":\"traceloop\",\"url\":\"https://www.traceloop.com/docs\",\"publisher\":{\"@id\":\"https://www.traceloop.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.traceloop.com/docs/openllmetry/tracing/association#webpage\",\"url\":\"https://www.traceloop.com/docs/openllmetry/tracing/association\",\"name\":\"Associating Entities with Traces\",\"description\":\"How to associate traces with entities in your own application\",\"dateModified\":\"2026-01-25T08:51:17.458Z\",\"isPartOf\":{\"@id\":\"https://www.traceloop.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://www.traceloop.com/docs/openllmetry/tracing/association#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.traceloop.com/docs/openllmetry/tracing/association#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Tracing\",\"item\":\"https://www.traceloop.com/docs/openllmetry/tracing/supported\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Associating Entities with Traces\",\"item\":\"https://www.traceloop.com/docs/openllmetry/tracing/association\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://www.traceloop.com/docs/openllmetry/tracing/association#article\",\"headline\":\"Associating Entities with Traces\",\"name\":\"Associating Entities with Traces\",\"description\":\"How to associate traces with entities in your own application\",\"url\":\"https://www.traceloop.com/docs/openllmetry/tracing/association\",\"mainEntityOfPage\":{\"@id\":\"https://www.traceloop.com/docs/openllmetry/tracing/association#webpage\"},\"dateModified\":\"2026-01-25T08:51:17.458Z\",\"publisher\":{\"@id\":\"https://www.traceloop.com/#organization\"},\"isPartOf\":{\"@id\":\"https://www.traceloop.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"traceloop\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"traceloop","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open","pages":[{"title":"Documentation","href":"/introduction"}]},{"anchor":"OpenLLMetry","icon":"telescope","groups":[{"group":"Introduction","pages":[{"title":"What is OpenLLMetry?","href":"/openllmetry/introduction"}]},{"group":"Quick Start","pages":[{"title":"Python","href":"/openllmetry/getting-started-python"},{"title":"Node.js","href":"/openllmetry/getting-started-ts"},{"title":"Next.js","href":"/openllmetry/getting-started-nextjs"},{"title":"Go","href":"/openllmetry/getting-started-go"},{"title":"Ruby","href":"/openllmetry/getting-started-ruby"},{"title":"SDK Initialization Options","href":"/openllmetry/configuration"},{"title":"Troubleshooting","href":"/openllmetry/troubleshooting"}]},{"group":"Tracing","pages":[{"title":"What's Supported?","href":"/openllmetry/tracing/supported"},{"title":"Multi-Modality Support","href":"/openllmetry/tracing/multi-modality"},{"title":"Workflow Annotations","href":"/openllmetry/tracing/annotations"},{"title":"Sessions","href":"/openllmetry/tracing/sessions"},{"title":"Versioning","description":"Learn how to enrich your traces by versioning your workflows and prompts","href":"/openllmetry/tracing/versions"},{"title":"Associating Entities with Traces","href":"/openllmetry/tracing/association"},{"title":"Tracking User Feedback","description":null,"href":"/openllmetry/tracing/user-feedback"},{"title":"Manually reporting calls to LLMs and Vector DBs","href":"/openllmetry/tracing/manual-reporting"},{"title":"Issues with Auto-instrumentation (Typescript / Javascript)","href":"/openllmetry/tracing/js-force-instrumentations"},{"title":"Usage with Threads (Python)","href":"/openllmetry/tracing/python-threads"},{"title":"Without OpenLLMetry SDK","href":"/openllmetry/tracing/without-sdk"}]},{"group":"Integrations","pages":[{"title":"Overview","href":"/openllmetry/integrations/introduction"},{"title":"LLM Observability with Traceloop","sidebarTitle":"Traceloop","href":"/openllmetry/integrations/traceloop"},{"title":"LLM Observability with Axiom and OpenLLMetry","sidebarTitle":"Axiom","href":"/openllmetry/integrations/axiom"},{"title":"Azure Application Insights","href":"/openllmetry/integrations/azure"},{"title":"LLM Observability with Braintrust and OpenLLMetry","sidebarTitle":"Braintrust","href":"/openllmetry/integrations/braintrust"},{"title":"LLM Observability with BMC and OpenLLMetry","sidebarTitle":"BMC Helix","href":"/openllmetry/integrations/bmc"},{"title":"LLM Observability with Dash0 and OpenLLMetry","sidebarTitle":"Dash0","href":"/openllmetry/integrations/dash0"},{"title":"LLM Observability with Datadog and OpenLLMetry","sidebarTitle":"Datadog","href":"/openllmetry/integrations/datadog"},{"title":"LLM Observability with Dynatrace and OpenLLMetry","sidebarTitle":"Dynatrace","href":"/openllmetry/integrations/dynatrace"},{"title":"LLM Observability with Elasticsearch APM Service","sidebarTitle":"Elasticsearch APM","href":"/openllmetry/integrations/elasticsearch-apm"},{"title":"LLM Observability with Google Cloud and OpenLLMetry","sidebarTitle":"Google Cloud","href":"/openllmetry/integrations/gcp"},{"title":"LLM Observability with Grafana and OpenLLMetry","sidebarTitle":"Grafana","href":"/openllmetry/integrations/grafana"},{"title":"LLM Observability with groundcover and OpenLLMetry","sidebarTitle":"groundcover","href":"/openllmetry/integrations/groundcover"},{"title":"LLM Observability with Highlight and OpenLLMetry","sidebarTitle":"Highlight","href":"/openllmetry/integrations/highlight"},{"title":"LLM Observability with Honeycomb and OpenLLMetry","sidebarTitle":"Honeycomb","href":"/openllmetry/integrations/honeycomb"},{"title":"LLM Observability with HyperDX and OpenLLMetry","sidebarTitle":"HyperDX","href":"/openllmetry/integrations/hyperdx"},{"title":"LLM Observability with Instana and OpenLLMetry","sidebarTitle":"Instana","href":"/openllmetry/integrations/instana"},{"title":"LLM Observability with KloudMate and OpenLLMetry","sidebarTitle":"KloudMate","href":"/openllmetry/integrations/kloudmate"},{"title":"LLM observability with Laminar and OpenLLMetry","sidebarTitle":"Laminar","href":"/openllmetry/integrations/laminar"},{"title":"Enhance LLM Observability with Langfuse and OpenLLMetry","sidebarTitle":"Langfuse","href":"/openllmetry/integrations/langfuse"},{"title":"LLM Observability with LangSmith and OpenLLMetry","sidebarTitle":"LangSmith","href":"/openllmetry/integrations/langsmith"},{"title":"LLM Observability with Middleware and OpenLLMetry","sidebarTitle":"Middleware","href":"/openllmetry/integrations/middleware"},{"title":"LLM observability with New Relic and OpenLLMetry","sidebarTitle":"New Relic","href":"/openllmetry/integrations/newrelic"},{"title":"LLM observability with OpenTelemetry Collector","sidebarTitle":"OpenTelemetry Collector","href":"/openllmetry/integrations/otel-collector"},{"title":"LLM Observability with Oracle Cloud Infrastructure Application Performance Monitoring(APM) service","sidebarTitle":"OCI Application Performance Monitoring","href":"/openllmetry/integrations/oraclecloud"},{"title":"LLM Observability with Scorecard and OpenLLMetry","sidebarTitle":"Scorecard","href":"/openllmetry/integrations/scorecard"},{"title":"LLM Observability with Service Now Cloud Observability and OpenLLMetry","sidebarTitle":"Service Now Cloud Observability","href":"/openllmetry/integrations/service-now"},{"title":"LLM Observability with SigNoz and OpenLLMetry","sidebarTitle":"SigNoz","href":"/openllmetry/integrations/signoz"},{"title":"LLM Observability with Sentry and OpenLLMetry","sidebarTitle":"Sentry","href":"/openllmetry/integrations/sentry"},{"title":"LLM Observability with Splunk and OpenLLMetry","sidebarTitle":"Splunk","href":"/openllmetry/integrations/splunk"},{"title":"LLM Observability with Tencent APM and OpenLLMetry","sidebarTitle":"Tencent Cloud","href":"/openllmetry/integrations/tencent"}]},{"group":"Privacy","pages":[{"title":"Prompts, Completions and Embeddings","href":"/openllmetry/privacy/traces"},{"title":"Telemetry","href":"/openllmetry/privacy/telemetry"}]},{"group":"Contribute","pages":[{"title":"Overview","href":"/openllmetry/contributing/overview"},{"title":"Local Development","href":"/openllmetry/contributing/developing"},{"title":"GenAI Semantic Conventions","href":"/openllmetry/contributing/semantic-conventions"}]}]},{"anchor":"Hub","icon":"arrows-to-dot","pages":[{"title":"Hub","href":"/hub/getting-started"}]},{"anchor":"Dashboard API","icon":"webhook","pages":[{"title":"Dashboard API","href":"/api-reference/introduction"}]},{"anchor":"Community","href":"https://traceloop.com/slack","icon":"slack"},{"anchor":"GitHub","href":"https://github.com/traceloop","icon":"github"}]},"basePath":"","title":"Associating Entities with Traces - traceloop","buildId":"dpl_BSPUBxEoKhhK7HzXVDPxdPvWx4xc","deploymentId":"dpl_BSPUBxEoKhhK7HzXVDPxdPvWx4xc","dynamics":[],"chunks":[]}