VibORM

Introduction

Add observability to your VibORM application with OpenTelemetry tracing and structured logging

Features

  • OpenTelemetry Tracing - Automatic span creation for all database operations
  • Structured Logging - Callback-based logging with level filtering
  • Graceful Degradation - Tracing works without OTel installed (no-op)
  • Serverless Compatible - No module-level state, safe for edge runtimes
  • Security Defaults - SQL shown by default, parameters hidden

Quick Example

import { VibORM } from "viborm";

// Simple: enable both with defaults
const client = VibORM.create({
  schema,
  driver,
  instrumentation: {
    tracing: true,  // Enable tracing with defaults
    logging: true   // Enable pretty console logging for all levels
  }
});

// Advanced: custom configuration
const clientAdvanced = VibORM.create({
  schema,
  driver,
  instrumentation: {
    tracing: {
      includeSql: true,    // Include SQL in spans (default: true)
      includeParams: false // Exclude params for security (default: false)
    },
    logging: {
      query: true,                       // Pretty console output
      error: (event, log) => {           // Custom callback
        errorTracker.capture(event.error);
        log();                           // Also use default logger
      }
    }
  }
});

Configuration

The instrumentation option accepts two optional configurations:

OptionDescription
tracingOpenTelemetry tracing configuration
loggingStructured logging configuration

Both are fully independent - you can enable one, both, or neither.

Privacy & Security

By default, VibORM includes SQL query text but excludes query parameters:

  • includeSql: true (default) - SQL statements are visible in traces/logs
  • includeParams: false (default) - Parameters are hidden to protect sensitive data

Only enable includeParams in development or staging environments. Query parameters may contain sensitive user data.

Next Steps

On this page