dbobs

package
v1.141.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package dbobs opens the platform's PostgreSQL pool through a driver wrapper that observes every statement (#1896): a client span per statement under the caller's span, a db_client_operation_duration_seconds{operation} observation, and a db_client_slow_statements_total count and WARN for a statement at or over the slow threshold.

The operation is the statement's leading keyword (select, insert, update, ...), vector_search for a statement that ranks by a pgvector distance, and the transaction or connection step otherwise (begin, commit, rollback, prepare, connect, ping). A vector search is its own operation and its own span name, so what vector ranking costs is separable from ordinary queries without touching the call sites that rank.

The SQL text is not on the span unless OTEL_TRACES_INCLUDE_DB_STATEMENT is set: a statement can quote the values it was built with, and a trace backend is outside the platform. A statement made outside any traced request (a background sweep) opens no span, so the trace backend does not fill with root spans nobody can place.

Index

Constants

View Source
const OpVectorSearch = "vector_search"

OpVectorSearch is the operation of a statement that ranks by a pgvector distance operator.

Variables

This section is empty.

Functions

func Open

func Open(dsn string, m *observability.Metrics) (*sql.DB, error)

Open opens the pool on dsn with every statement observed, recording through m (nil records nothing) and reading the slow threshold and the statement opt-in from the environment (observability.DBConfigFromEnv).

func Operation

func Operation(method otelsql.Method, query string) string

Operation is the bounded operation a driver call is measured under.

func Options

Options are the driver wrapper's options for m and cfg.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL