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

# Factory Droid

> Pin a telemetry block in Factory's org-managed settings to ship Factory Droid usage metrics, or GenAI spans for every turn, model call, and tool run, to Sazabi.

[All Factory Droid integration capabilities](https://docs.sazabi.com/catalogs/integrations/factory-droid)

## About

Ship Factory Droid telemetry to Sazabi using Droid's built-in OpenTelemetry exporter. An organization admin pins one `telemetry` block in Factory's managed settings, and every member's Droid sessions send data to Sazabi — members cannot redirect or switch it off from their own machines.

Droid sends one of two formats:

* **`legacy`** (Factory's default) — the `droid.*` usage metrics: `droid.session.count`, `droid.tool.invocations`, `droid.tool.execution_time`, `droid.code.lines_modified`, `droid.git.commits`, `droid.git.pull_requests`, and more. Each data point arrives as one line carrying `session.id`, `user.email`, and `model.id`.
* **`genai`** — one trace per user turn: an `invoke_agent droid` span with `chat <model>` and `execute_tool <tool>` children carrying `gen_ai.conversation.id`, `gen_ai.request.model`, `gen_ai.provider.name`, `gen_ai.tool.name`, and `error.type`, plus `gen_ai.*` duration histograms.

The two formats replace each other; they do not stack. Prompt, response, and tool content is **not** exported unless you opt in.

> [!WARNING]
>
> Setting `logMessageContent` to `true` exports raw prompts, model responses, tool arguments, and tool results with no redaction or secret detection. Leave it at `false` unless you understand the privacy implications for your team.

## Prerequisites

* Factory Droid (`droid`) CLI in use by your team
* A Factory organization admin with access to Enterprise Controls
* Your Sazabi intake URL, shown above — open the log source and copy the **Intake URL** from its setup screen (the public key is embedded in the URL)

## Set up in the dashboard

**Step 1**

### Pin the telemetry block

In the [Factory App](https://app.factory.ai), open **Settings → Enterprise Controls → Raw Configuration** and add the following block (merge it into any existing JSON):

```json title="Raw Configuration" theme={"system"}
{
  "telemetry": {
    "enabled": true,
    "endpoint": "<your intake URL>",
    "metricExportIntervalMs": 60000,
    "logMessageContent": false,
    "granularity": "user",
    "format": "legacy"
  }
}
```

Replace `<your intake URL>` with the intake URL shown above. Pass the bare URL — Droid appends `/v1/metrics` and `/v1/traces` itself. The public key is part of the URL, so no `headers` entry is needed.

Set `"format"` to `"genai"` to receive GenAI spans instead of `droid.*` metrics. Sazabi is not a metrics store: it stores each metric data point as its own log line, so raise `metricExportIntervalMs` to send fewer, larger batches.

Droid honors the `telemetry` block only at the organization level. Fleets managed without the Factory App can place the same JSON in the system-managed settings file instead: `/etc/factory/settings.json` (Linux and WSL), `/Library/Application Support/Factory/settings.json` (macOS), or `C:\Program Files\Factory\settings.json` (Windows).

**Step 2**

### Start a new droid session

Droid reads the block once, at startup. Telemetry begins with each member's next session, not one that is already running. Sessions started while logged out have no organization settings to read and fall back to the local `OTEL_*` environment.

To try Droid on a single machine before pinning the block for everyone, export `OTEL_TELEMETRY_ENDPOINT="<your intake URL>"` (and `OTEL_TELEMETRY_FORMAT=genai` for spans) in the shell that starts `droid`. An organization block, once set, takes precedence.

## Set up with the CLI

You can also register the Factory Droid log source with the [Sazabi CLI](https://docs.sazabi.com/reference/cli.md) (installed and authenticated — see [CLI reference](https://docs.sazabi.com/reference/cli/log-sources.md)).

Registering the source mints the same intake URL the dashboard shows above (the public key is embedded in its hostname):

```bash theme={"system"}
sazabi log-sources create factory_droid --mode manual
```

The command prints the intake URL for the new source — copy the whole URL and use it as the `endpoint` in the block shown above. Run `sazabi log-sources get <log-source-id>` at any time to reprint the endpoint, or `sazabi log-sources list` to see every log source in the project.

## Verify

Start a new droid session after the block is saved and send one prompt. Droid flushes metrics every `metricExportIntervalMs` (60 seconds above) and on exit. Open the [Intake page](https://docs.sazabi.com/guides/instrument/intake.md) in the Sazabi dashboard and confirm lines from the **Factory Droid** source appear within a couple of minutes.

From the CLI, `sazabi logs ask "How many Factory Droid log lines arrived in the last 15 minutes?"` confirms lines are arriving, and `sazabi logs ask "Tool invocations per user.email from Factory Droid in the last day"` breaks usage down by person. With `genai`, search for a `gen_ai.conversation.id` value to view every span from a single session.

## Troubleshooting

**Nothing arrives after saving the block** — Confirm the member started a new droid session after the change, while logged in. Sessions that were already running keep their previous settings.

**Only some members report** — Members whose sessions started before the change, or that run logged out, are still on their local settings. Ask them to restart droid.

**No spans arrive** — Expected under `legacy`, which sends spans only when message content logging is on. Set `"format": "genai"` to receive spans without content.

**User identity is missing** — `"granularity"` is set to `"aggregate"`, which strips `user.id` and `user.email` and disables content export. Set it to `"user"` to attribute usage to people.

**Token counts and cost are missing** — Droid does not include them in its OpenTelemetry export. Factory reports them only through its hosted [Analytics API](https://docs.factory.com/api-reference/analytics).

## Further reading

> [card] [Factory telemetry](https://docs.factory.com/enterprise/telemetry)
>
> Factory's reference for the telemetry block and environment variables.

> [card] [Factory telemetry data reference](https://docs.factory.com/enterprise/telemetry/data-reference)
>
> Every metric, span, and attribute Droid exports.

> [card] [Intake](https://docs.sazabi.com/guides/instrument/intake.md)
>
> See per-source ingestion volume and health.

> [card] [Log sources](https://docs.sazabi.com/catalogs/log-sources.md)
>
> Browse the full log source catalog.


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