Skip to content
rawtreedbPublic

About

RawTree examples

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

RawTree Examples

Examples for sending agent and sandbox telemetry to RawTree.

Examples

sandboxes/vercel-ai-sandbox.ts

Minimal TypeScript script that sends OpenTelemetry traces from a Vercel Sandbox agent run to RawTree with the otlp-traces transform.

The demo uses:

  • OpenTelemetry Node SDK and OTLP HTTP exporter for trace export
  • @vercel/sandbox for the full VM sandbox
  • bash-tool for the AI SDK bash/read/write toolset
  • @rawtree/sdk to query the ingested trace rows after the run
  • A terminal trace renderer that groups spans by traceId and parentSpanId

sandboxes/daytona.ts

Minimal TypeScript script that creates a Daytona TypeScript sandbox, runs a small code snippet, and sends Daytona SDK native OpenTelemetry signals to RawTree's OTLP endpoint.

The demo uses:

  • Daytona SDK native OpenTelemetry instrumentation
  • RawTree's default OTLP tables for traces, metrics, and logs

sandboxes/modal.py

Minimal Python script based on Modal's hello-world example. It relies on Modal's workspace OpenTelemetry integration to send function logs and metrics to RawTree's default OTLP tables.

Create the Modal OTEL secret with:

modal secret create rawtree-otel \
  OTEL_HEADER_Authorization="Bearer $RAWTREE_API_KEY"

otel/logs.ts

Node.js OpenTelemetry logs example adapted from PostHog's OTLP logs setup to RawTree. It sends log records to a RawTree table using the otlp-logs transform, then queries the inserted rows by a generated demo.run_id.

The RawTree OTLP logs endpoint is:

https://api.rawtree.com/v1/tables/otel_logs?transform=otlp-logs

otel/traces.ts

Node.js OpenTelemetry traces example for RawTree. It creates a small parent-child span tree, exports it to RawTree with the otlp-traces transform, then queries the inserted rows by traceId and prints the trace timeline.

The RawTree OTLP traces endpoint is:

https://api.rawtree.com/v1/tables/otel_traces?transform=otlp-traces

postgres/supabase-etl/

Rust example that uses supabase/etl to stream rows from a Supabase Postgres publication into a RawTree table.

The demo uses:

  • Supabase direct Postgres connection for logical replication
  • Supabase ETL's Rust pipeline and in-memory store
  • A RawTree destination that accepts changing row shapes

open-agents/

Vendored copy of vercel-labs/open-agents for adapting its agent metrics, user-facing activity, and leaderboard surfaces to RawTree. See open-agents/RAWTREE.md for source provenance and adaptation notes.

Setup

.env.local already needs:

RAWTREE_API_KEY=...

The Daytona sandbox example also needs:

DAYTONA_API_KEY=...

The Supabase Postgres example also needs:

DATABASE_URL=postgres://postgres:<password>@db.<project-ref>.supabase.co:5432/postgres?sslmode=require
POSTGRES_TLS_ROOT_CERT_PATH=./supabase-ca.pem
POSTGRES_PUBLICATION=rawtree_publication

Use the Supabase direct database URL for this example, not the pooler URL, because logical replication requires direct replication slots.

Add one model credential path:

OPENAI_API_KEY=...
# or
AI_GATEWAY_API_KEY=...
AI_MODEL=openai/gpt-5

The Vercel Sandbox SDK also needs local Vercel project auth, typically from:

vercel link
vercel env pull .env.local

Run

npm install
npm run sandboxes:modal
npm run sandboxes:daytona
npm run sandboxes:vercel-ai
npm run otel:logs
npm run otel:traces
npm run postgres:supabase

The script prints the generated run_id and trace_id, runs the agent, flushes traces to RawTree, then queries agent_sandbox_traces for the full trace and prints a terminal timeline.

Example shape:

RawTree trace timeline
trace_id  ...
run_id    ...
table     agent_sandbox_traces
spans     12 | duration 4.00s | service rawtree-vercel-ai-sandbox

 +0.00ms    4.00s OK demo.run INTERNAL
    |-- +100.0ms  700.0ms OK sandbox.create INTERNAL
    |   provider=vercel  runtime=node24  sandbox=...
    `--   +1.00s  800.0ms OK ai.toolCall INTERNAL
        operation=ai.toolCall  scope=ai  tool=bash
        `--   +1.10s  500.0ms OK sandbox.bash INTERNAL
            command=node -e "..."  exit=0  stdout_bytes=23

The example declares the trace service and destination table in code:

const telemetry = registerRawTreeOtel({
  serviceName: "rawtree-vercel-ai-sandbox",
  tableName: "agent_sandbox_traces",
});

TypeScript

The runnable sandbox example lives in sandboxes/vercel-ai-sandbox.ts. Shared OpenTelemetry setup lives in lib/register-otel.ts. It exports registerRawTreeOtel, a generic Node OpenTelemetry registration helper that sends OTLP traces to RawTree's otlp-traces transform.

The reusable terminal renderer lives in lib/trace-timeline.ts.

npm run check

About

RawTree examples

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages