OpenTelemetry Psycopg Integration¶
The integration with PostgreSQL supports the Psycopg library, it can be enabled by
using Psycopg2Instrumentor.
Usage¶
import psycopg2
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.ext.psycopg2 import Psycopg2Instrumentor
trace.set_tracer_provider(TracerProvider())
Psycopg2Instrumentor().instrument()
cnx = psycopg2.connect(database='Database')
cursor = cnx.cursor()
cursor.execute("INSERT INTO test (testField) VALUES (123)")
cursor.close()
cnx.close()
API¶
-
class
opentelemetry.ext.psycopg2.Psycopg2Instrumentor[source]¶ Bases:
opentelemetry.auto_instrumentation.instrumentor.BaseInstrumentor