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

# Advanced Instrumentation

> Advanced instrumentation for your AI agent workflows

By default, Atla instrumentation automatically captures LLM generations and agent framework information when available.

This is great, but especially complex workflows often require more granular tracking, such as define which LLM generations belong to which agent execution.

Advanced instrumentation gives you the tools to capture this additional context and create more meaningful traces.

## Instrumenting Functions

<CodeGroup>
  ```python icon="python" lines theme={null}
  from atla_insights import instrument

  @instrument("My Customer Support Agent")  # [!code ++]
  def my_customer_support_agent():
      ...

  @instrument("My Analysis Agent")  # [!code ++]
  def my_analysis_agent():
      ...

  @instrument("My Orchestrator")  # [!code ++]
  def my_orchestrator(task: str):
      if task == "customer_support":
          my_customer_support_agent()
      elif task == "analysis":
          my_analysis_agent()
      else:
          ...
  ```

  ```typescript icon="square-js" lines theme={null}
  import { instrument } from "@atla-ai/insights-sdk-js";

  async function myCustomerSupportAgent(): Promise<void> {
    // ...
  };
  const myInstrumentedCustomerSupportAgent = instrument("My Customer Support Agent")(myCustomerSupportAgent);  // [!code ++]

  async function myAnalysisAgent(): Promise<void> {
    // ...
  };
  const myInstrumentedAnalysisAgent = instrument("My Analysis Agent")(myAnalysisAgent);  // [!code ++]

  async function myOrchestrator(task: string): Promise<void> {
    if (task === "customer_support") {
      await myInstrumentedCustomerSupportAgent();
    } else if (task === "analysis") {
      await myInstrumentedAnalysisAgent();
    } else {
      ...
    }
  };
  const myInstrumentedOrchestrator = instrument("My Orchestrator")(myOrchestrator);  // [!code ++]
  ```
</CodeGroup>

<Info>
  As a best practice, we recommend wrapping the orchestrating function in your application.

  If you have a multi-agent system, we recommend wrapping each agents' functions as well.
</Info>
