---
title: "Function: getTracer()"
editUrl: true
head: []
template: doc
sidebar:
  hidden: false
  attrs: {}
pagefind: true
draft: false
---

[**Prefactor TypeScript SDK**](../../../index.md)

***

[Prefactor TypeScript SDK](../../../modules.md) / [@prefactor/ai](../index.md) / getTracer

# Function: getTracer()

> **getTracer**(): `Tracer`

Defined in: [packages/ai/src/init.ts:198](https://github.com/prefactordev/typescript-sdk/blob/36c73ff31a0d7edab73280c2f46cb7ce554a63e9/packages/ai/src/init.ts#L198)

Get the current tracer instance.

If no tracer has been created yet, this will call init() with default configuration.

## Returns

`Tracer`

Tracer instance

## Example

```typescript
import { getTracer } from '@prefactor/ai';

const tracer = getTracer();
// Use for custom span creation
const span = tracer.startSpan({
  name: 'custom-operation',
  spanType: SpanType.CHAIN,
});
```