> ## Documentation Index
> Fetch the complete documentation index at: https://platform.atlan.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To act on Atlan objects, use the Atlan MCP server at https://api.atlan.com/mcp or the atlanai CLI; `atlanai --map json` prints its command map. Run a read-only identity check before any write.
> The docs MCP server at /mcp searches these docs only. It cannot read or change Atlan objects.
> SDK packages: Python `atlanai` (PyPI) and TypeScript `@atlanai/sdk` (npm). Show Python first, then TypeScript.

# Group runs into sessions

> Stamp session, user, visitor, and tags on every span in a run with propagate_attributes in atlanai SDK.

<Badge color="blue">SDK 0.4.0</Badge>

`propagate_attributes` in atlanai SDK stamps association attributes onto every span started in its scope, including spans from third-party instrumentation you do not control. Use it to group traces into one session in Agent Registry and to attach a user, tags, or display name. To set the trace ID itself, use [Set deterministic trace ID](/tools/sdk/how-tos/set-trace-id).

## Before you begin

Before you start, make sure you have:

* **SDK**: atlanai SDK installed with tracing, as in [Install atlanai SDK](/tools/sdk/how-tos/install).
* **Tracing**: `init` configured and exporting, as in [Trace first agent run](/tools/sdk/tutorials/quickstart).

<Steps>
  <Step title="Wrap run in propagation scope">
    Run the agent inside the scope. Python arguments are keyword-only.

    <Tabs>
      <Tab title="Python">
        ```python theme={null}
        from atlanai.tracing import propagate_attributes

        with propagate_attributes(
            session_id="ticket-4821",
            user_id="user-123",
            tags=["support", "escalated"],
            trace_name="zendesk:4821",
        ):
            run_agent(thread)
        ```
      </Tab>

      <Tab title="TypeScript">
        ```typescript theme={null}
        import { propagateAttributes } from "@atlanai/sdk/tracing";

        await propagateAttributes(
          {
            sessionId: "ticket-4821",
            userId: "user-123",
            tags: ["support", "escalated"],
            traceName: "zendesk:4821",
          },
          async () => {
            await runAgent(thread);
          },
        );
        ```
      </Tab>
    </Tabs>

    `session_id` groups traces into one session. `trace_name` overrides the trace display name, which helps when the root span name is generic but the run has a meaningful external label. `visitor_id` attaches a visitor identity. Use a stable pseudonymous ID for `user_id`, not an email address.
  </Step>

  <Step title="Verify attributes">
    Flush, then open the trace in Agent Registry. Confirm every span, including framework spans, carries the session, user, and tags, and that the run appears under the session.

    If no trace appears, see [`init()` disables tracing and no traces are exported](/tools/sdk/troubleshooting/install-and-setup-errors#init-disables-tracing-and-no-traces-are-exported).
  </Step>
</Steps>

## Troubleshooting

If traces do not appear, see [Install and setup errors](/tools/sdk/troubleshooting/install-and-setup-errors).

## Next steps

* [Set deterministic trace ID](/tools/sdk/how-tos/set-trace-id): make retries converge on one trace.

## See also

* [Create spans for agent run](/tools/sdk/how-tos/tracing)
* [Control trace privacy](/tools/sdk/how-tos/privacy)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.