Skip to content

pg_agenttrace

AlohaDB OTLP trace storage, agent span trees and usage rollups

alohadb · AlohaDB OTLP trace storage, agent span trees and usage rollups

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102460pg_agenttracealohadb1.0STATMITSQL

PostgreSQL · 18

Relationships
Requiresplpgsql

Usage

Sources:

pg_agenttrace 1.0 stores OpenTelemetry agent traces, exposes span trees and usage rollups, and can estimate GenAI costs from an administrator-maintained price table.

These are preview modules of AlohaDB 21.2.0, a PostgreSQL 18 fork. Compatibility with stock PostgreSQL is not established.

Enable and Ingest

A superuser installs the SQL/PLpgSQL extension in its fixed agenttrace schema. Direct SQL ingestion requires no preload or restart. The optional HTTP receiver is supplied separately by pg_restapi.

CREATE EXTENSION pg_agenttrace;
SELECT agenttrace.agenttrace_ingest_span(
  '0123456789abcdef0123456789abcdef', '0123456789abcdef',
  'agent.run', now(), service_name => 'agent-demo');
SELECT * FROM agenttrace.agenttrace_tree(
  agenttrace.agenttrace_trace_id('0123456789abcdef0123456789abcdef'));
SELECT * FROM agenttrace.agenttrace_rollup(interval '1 hour', now() - interval '1 day', now());

agenttrace_ingest_otlp(jsonb) accepts an OTLP/JSON ExportTraceServiceRequest and returns the number of newly inserted spans; repeated identities are idempotent. agenttrace_ingest_span accepts a 32-hex trace ID and a 16-hex span ID. Invalid identifiers or timestamps fail the call.

Privileges and Retention

PUBLIC access to extension tables and functions is revoked. Administrators use agenttrace_grant_writer and agenttrace_grant_reader for explicit role grants. Ingest functions are SECURITY DEFINER with a pinned search path; those grants authorize database access, not per-tenant isolation. Traces may contain prompts, tool arguments and credentials, so limit writers/readers and redact at the source.

Data is partitioned by UTC day. Automatic creation accepts dates from 31 days in the past through 2 days in the future and creates at most 4 new days per batch. Administrators can precreate a range with agenttrace_ensure_partitions and remove old data with agenttrace_drop_partitions; dropping partitions permanently removes their spans. Late or out-of-range data needs an explicit retention/partition decision.

The price table starts empty: a missing estimate is not zero cost. Graph registration/synchronization and Parquet export are optional integrations and require the matching AlohaDB modules and privileges. Keep database backups; rollups and exported partitions are not a substitute for the original trace corpus.

Table reader