Opentelemetry Psycopg instrumentor that wraps psycopg connections to emit tracing spans.
# Source: https://github.com/open-telemetry/opentelemetry-python-contrib | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
"""
The integration with PostgreSQL supports the `Psycopg`_ library. It can be enabled by
using ``PsycopgInstrumentor``.
.. _Psycopg: https://www.psycopg.org/psycopg3/docs/
Usage
-----
.. code-block:: python
import psycopg
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
# Call instrument() to wrap all database connections
PsycopgInstrumentor().instrument()
cnx = psycopg.connect(database="Database")
cursor = cnx.cursor()
cursor.exec
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key