{"id":24150,"library":"opencensus-ext-sqlalchemy","title":"OpenCensus SQLAlchemy Integration","description":"OpenCensus SQLAlchemy Integration provides tracing instrumentation for SQLAlchemy queries. It wraps SQLAlchemy engine events to capture spans for each executed query, including bind parameters and execution time. Version 0.1.3 is current, with irregular releases.","status":"active","version":"0.1.3","language":"python","source_language":"en","source_url":"https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-sqlalchemy","tags":["opencensus","sqlalchemy","tracing","instrumentation","monitoring"],"install":[{"cmd":"pip install opencensus-ext-sqlalchemy","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core OpenCensus library for tracing and exporting","package":"opencensus","optional":false},{"reason":"Instrumented ORM/engine","package":"sqlalchemy","optional":false},{"reason":"Export traces to Azure Monitor (common exporter)","package":"opencensus-ext-azure","optional":true}],"imports":[{"wrong":"from opencensus.ext.sqlalchemy.trace import SQLAlchemyTrace","symbol":"SQLAlchemyTrace","correct":"from opencensus.ext.sqlalchemy import SQLAlchemyTrace"}],"quickstart":{"code":"import os\nfrom opencensus.ext.sqlalchemy.trace import SQLAlchemyTrace\nfrom sqlalchemy import create_engine\n\n# Create engine\nengine = create_engine('sqlite:///:memory:')\n\n# Instrument with OpenCensus tracer\ntracer = SQLAlchemyTrace(engine)\n\n# Now every query executed via this engine will be traced\nwith engine.connect() as conn:\n    conn.execute(\"SELECT 1\")\n","lang":"python","description":"Instrument a SQLAlchemy engine to trace queries."},"warnings":[{"fix":"Apply SQLAlchemyTrace immediately after engine creation, before first use.","message":"SQLAlchemyTrace must wrap the engine before any queries are executed. Instrumentation after connections have been created will not capture traces for those connections.","severity":"gotcha","affected_versions":"all"},{"fix":"Set up OpenCensus tracing with an exporter, e.g., 'from opencensus.trace import tracer as tracer_module' and configure with a sampler and exporter.","message":"The package does not automatically export traces; you must configure an exporter (e.g., Azure Monitor, Zipkin) via OpenCensus tracing. Without an exporter, no data is sent anywhere.","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to OpenTelemetry with opentelemetry-instrumentation-sqlalchemy.","message":"OpenCensus Python is in maintenance mode and no longer actively developed. Google recommends using OpenTelemetry instead. However, the extension still works for existing users.","severity":"deprecated","affected_versions":">=0.11.0"}],"env_vars":null,"search_vec":"'0.1.3':32 'bind':26 'captur':19 'current':34 'engin':16 'event':17 'execut':23,29 'includ':25 'instrument':9,41 'integr':3,6 'irregular':36 'monitor':42 'opencensus':1,4,38 'paramet':27 'provid':7 'queri':12,24 'releas':37 'span':20 'sqlalchemi':2,5,11,15,39 'time':30 'trace':8,40 'version':31 'wrap':14","created_at":"2026-05-01T08:11:32.797429+00:00","updated_at":"2026-05-01T08:11:32.797429+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'SQLAlchemyTrace' from 'opencensus.ext.sqlalchemy' (/tmp/tmps6d8ck8a/venv/lib/python3.12/site-packages/opencensus/ext/sqlalchemy/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/census-instrumentation/opencensus-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/opencensus-ext-sqlalchemy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}