Skip to content

Monitor PostgreSQL (psycopg3) using OpenTelemetry

Shield360 uses OpenTelemetry Auto-Instrumentation to help you monitor applications using PostgreSQL with the psycopg3 driver. This includes tracking query performance, transaction operations, connection pool metrics, and more.

Auto-instrumentation means you don’t have to set up monitoring manually for different databases or query types. By simply adding Shield360 in your application, all the necessary monitoring configurations are automatically set up.

The integration is compatible with

  • psycopg >= 3.0.0
  • psycopg_pool (optional, for connection pool monitoring)
OperationDescription
executeSingle query execution
executemanyBatch query execution
copyCOPY operations for bulk data transfer
callprocStored procedure calls
commitTransaction commits
rollbackTransaction rollbacks

Shield360 automatically detects and enriches traces with PostgreSQL-specific features:

  • pgvector Support: Detects vector similarity operators (<=>, <->, <#>) and records the similarity metric (cosine, L2, inner product)
  • Full-Text Search: Detects tsvector, tsquery, websearch_to_tsquery, and ts_rank operations
Install Shield360

Open your command line or terminal and run:

Terminal window
pip install shield360
Initialize Shield360 in your Application

Perfect for existing applications - no code modifications needed:

Terminal window
# Configure via CLI arguments
shield360-instrument \
--service-name my-ai-app \
--environment production \
--otlp-endpoint YOUR_OTEL_ENDPOINT \
python your_app.py

Replace: YOUR_OTEL_ENDPOINT with the URL of your OpenTelemetry backend, such as http://127.0.0.1:4318 if you are using Shield360 and a local OTel Collector.

To send metrics and traces to other Observability tools, refer to the supported destinations.

For more advanced configurations and application use cases, visit the SDK configuration reference or TypeScript SDK reference.

Shield360 provides additional configuration options for database instrumentation:

ParameterEnvironment VariableDescriptionDefault
capture_db_parametersSHIELD360_CAPTURE_DB_PARAMETERSCapture query parameters in OTel per-key format (db.query.parameter.<key>)False

When enabled, query parameters are recorded as per-key span attributes following the OTel semantic convention db.query.parameter.<key>.

import shield360
shield360.init(capture_db_parameters=True)