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

> ## Agent Instructions
> Application code puts a TableModel in app.py, then runs `pxt schema update app.py my_app` to create the tables and `pxt service update app.py my_app` to start HTTP. The last argument can be a Cloud URL such as `pxt://org:db`. Do not call pxt.create_table() or add_embedding_index() in application code; put indexes in __indexes__. Notebooks, tests, and the REPL do use pxt.create_table().
> Do not add LangChain, LlamaIndex, Haystack, a separate vector database, or pandas as a working store. Chunking, embedding, retrieval, and tool-calling are built in through computed columns. Use a computed column instead of a per-row loop that calls a model.
> Install with `pip install -U 'pixeltable[serve]'` on Python 3.11+. `pxt init` is a prerequisite for `pxt schema update`.
> For Pixeltable Cloud, point users to https://docs.pixeltable.com/cloud, which goes from `pxt login` to a running service.

# pixeltable

> <a href="https://github.com/pixeltable/pixeltable/blob/main/opentelemetry/instrumentation/pixeltable/__init__.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# module  opentelemetry.instrumentation.pixeltable

OpenTelemetry instrumentation for Pixeltable.

Translates Pixeltable's instrumentation hooks into OpenTelemetry spans and metrics. Instrumentation is
opt-in: either attach to an existing OpenTelemetry SDK with
[PixeltableInstrumentor](https://docs.pixeltable.com/sdk/v0.7.26/pixeltableinstrumentor.md), or let
[init](https://docs.pixeltable.com/sdk/v0.7.26/pixeltable.md#func-init) build providers from Pixeltable's `[otel]` config.

## func  init()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
init(
    *,
    endpoint: str | None = None,
    protocol: str | None = None,
    service_name: str | None = None,
    headers: str | None = None,
    span_level: Literal['info', 'debug', 'trace'] | None = None,
    span_dump: str | None = None,
    metrics: bool | None = None,
    logs: bool | None = None,
    tracer_provider: Any = None,
    meter_provider: Any = None
) -> None
```

Configure pixeltable's OpenTelemetry instrumentation and start emitting telemetry.

Call once, before the first Pixeltable operation. Each argument overrides the matching `[otel]`
config setting and its standard `OTEL_*` environment variable; when an argument is left as None the
value resolves from the database's `[[pixeltable.database]]` entry where it sets one (the endpoint and
protocol, as `db_<key>`), then that env var, then the `[otel]` config section. On the pods of a hosted
database, init() skips the entry's endpoint and protocol and reads them from the pod's environment. Pass
`tracer_provider`/`meter_provider` to instrument against an SDK your application owns instead.

**Parameters:**

* **`endpoint`** (`str | None`): OTLP collector endpoint (eg `http://localhost:4318`); resolves from the database entry's
  `db_exporter_otlp_endpoint`, then `OTEL_EXPORTER_OTLP_ENDPOINT`, then `otel.exporter_otlp_endpoint`.
  On the pods of a hosted database, init() skips the entry's `db_exporter_otlp_endpoint`. With no
  endpoint configured, no `span_dump`, and no application-owned provider, instrumentation stays inert and
  exports nothing.
* **`protocol`** (`str | None`): OTLP transport, `http/protobuf` (default) or `grpc`; resolves from the database entry's
  `db_exporter_otlp_protocol`, then `OTEL_EXPORTER_OTLP_PROTOCOL`, then `otel.exporter_otlp_protocol`.
  On the pods of a hosted database, init() skips the entry's `db_exporter_otlp_protocol`.
* **`service_name`** (`str | None`): `service.name` resource attribute (default `pixeltable`); resolves from
  `otel.service_name` / `OTEL_SERVICE_NAME`.
* **`headers`** (`str | None`): OTLP headers as comma-separated `key=value` pairs; resolves from
  `otel.exporter_otlp_headers` / `OTEL_EXPORTER_OTLP_HEADERS`.
* **`span_level`** (`Literal['info', 'debug', 'trace'] | None`): span emission threshold: `info` (default; operation spans plus their catalog, store, and
  SQL work spans), `debug` (adds per-row, per-UDF, per-file, and finer-grained catalog and store spans),
  or `trace` (adds a span per iterator step).
* **`span_dump`** (`str | None`): path of a file to append every finished span to, one JSON object per line; resolves
  from `otel.span_dump` / `OTEL_SPAN_DUMP`. Spans are written synchronously, so the file is
  complete even if the process dies. Works with or without an OTLP endpoint.
* **`metrics`** (`bool | None`): force metric export on/off (by default metrics are exported only when an OTLP endpoint
  is configured).
* **`logs`** (`bool | None`): force export of the `pixeltable`, `sqlalchemy.engine`, and `uvicorn` log records on/off (default
  off; must be explicitly enabled).
* **`tracer_provider`** (`Any`): an existing TracerProvider to instrument against.
* **`meter_provider`** (`Any`): an existing MeterProvider to instrument against.

**Examples:**

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import opentelemetry.instrumentation.pixeltable as pxt_otel

pxt_otel.init(endpoint='http://localhost:4318')
```


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