{ "info": { "author": "SignalFx, Inc.", "author_email": "info@signalfx.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "#########################\nPython DB API OpenTracing\n#########################\n\nThis package enables distributed tracing in `Python Database API 2.0`_ compatible-clients\nvia `The OpenTracing Project`_. Once a production system contends with real concurrency or splits\ninto many services, crucial (and formerly easy) tasks become difficult: user-facing latency optimization,\nroot-cause analysis of backend errors, communication about distinct pieces of a now-distributed system,\netc. Distributed tracing follows a request on its journey from inception to completion from mobile/browser\nall the way to the microservices. \n\nAs core services and libraries adopt OpenTracing, the application builder is no longer burdened with\nthe task of adding basic tracing instrumentation to their own code. In this way, developers can build\ntheir applications with the tools they prefer and benefit from built-in tracing instrumentation.\nOpenTracing implementations exist for major distributed tracing systems and can be bound or swapped\nwith a one-line configuration change.\n\nIf you want to learn more about the underlying Python API, visit the Python `source code`_.\n\n.. _Python Database API 2.0: https://www.python.org/dev/peps/pep-0249/\n.. _The OpenTracing Project: http://opentracing.io/\n.. _source code: https://github.com/signalfx/python-dbapi/\n\nInstallation\n============\n\nRun the following command:\n\n.. code-block:: \n\n $ pip install dbapi-opentracing\n\nUsage\n=====\n\nThis DB API extension allows the tracing of database queries using the OpenTracing API. All that it\nrequires is for a ``ConnectionTracing`` tracer to be initialized using an instance of an OpenTracing 2.0-compatible\ntracer and a DB API ``Connection`` object. You can either trace all commands sent to your database, or\nuse a ``Cursor`` to trace individual requests.\n\nInitialize\n----------\n\n``ConnectionTracing`` wraps the ``Connection`` and ``Tracer`` instances that are supported by the Python\nDB API and OpenTracing, respectively. To create a ``ConnectionTracing`` object, you can either pass in a\ntracer object directly or default to the ``opentracing.tracer`` global tracer:\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n tracing = ConnectionTracing(connection, opentracing_tracer)\n\nor\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n import db_api_compatible_client\n import opentracing\n\n opentracing.tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n tracing = ConnectionTracing(connection)\n\nFor expanded usage with Psycopg connection factories, a ``PsycopgConnectionTracing`` class is also available. This\nis necessary for directly using extensions and extras functions on traced connections. Its non-default usage requires a\nlambda proxy or closure to account for the expected tracing arguments, while using the global tracer and default allow\nit to be passed directly:\n\n .. code-block:: python\n\n from dbapi_opentracing import PsycopgConnectionTracing\n import opentracing\n import psycopg2\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n my_tags = dict(some='tag')\n tracing = psycopg2.connect(\n ..., connection_factory=lambda dsn: PsycopgConnectionTracing(dsn, tracer=opentracing_tracer, span_tags=my_tags)\n )\n\n # or to use all defaults\n opentracing.tracer = opentracing_tracer\n tracing = psycopg2.connect(..., connection_factory=PsycopgConnectionTracing)\n\nConnectionTracing Configuration\n-------------------------------\n\nAlong with optionally providing an OpenTracing 2.0-compatible tracer, ``ConnectionTracing`` also accepts a ``span_tags``\nnamed argument and several traced method disabling flags: ``trace_execute``, ``trace_executemany``,\n``trace_callproc``, ``trace_commit``, and ``trace_rollback`` to specify the command types you'd like not to trace\n(all are ``True`` by default).\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n from opentracing.ext import tags\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n tracing = ConnectionTracing(connection, opentracing_tracer,\n # span_tags will be used for all generated spans\n span_tags={'Custom': 'Tag', tags.DATABASE_TYPE: 'PostgreSQL',\n tags.DATABASE_INSTANCE='myDatabase'},\n trace_callproc=False, trace_commit=False)\n # Note that the default OpenTracing 'db.type' and 'db.instance' tags will both have 'sql' as their value.\n # If a more specific type is desired, you can set it with the span_tags dictionary argument as shown.\n\nTrace All Cursor Commands\n-------------------------\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n tracing = ConnectionTracing(connection, opentracing_tracer,\n span_tags={'Custom': 'Tag'}) # span_tags will be used for all generated spans\n\n # Please note that the default OpenTracing 'db.type' tag will have 'sql' as a value.\n # If a more specific type is desired, you can set it with the span_tags dictionary argument\n\n with tracing.cursor() as cursor:\n cursor.execute('SELECT * FROM TABLE')\n vals = cursor.fetchall()\n cursor.executemany('INSERT INTO TABLE VALUES (%s, %s)',\n [('one', 'two'), ('three', 'four')])\n cursor.callproc('MyStoredProcedure')\n tracing.commit()\n\nTrace Specific Cursor Command Types\n-----------------------------------\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n tracing = ConnectionTracing(connection, opentracing_tracer,\n span_tags={'Custom': 'Tag'}) # span_tags will be used for all generated spans\n\n # Provide False values for optional trace_execute, trace_executemany, and/or trace_callproc named arguments\n with tracing.cursor(trace_executemany=False, trace_callproc=False) as cursor:\n # Traced query\n cursor.execute('SELECT * FROM TABLE')\n vals = cursor.fetchall()\n # Untraced command\n cursor.executemany('INSERT INTO TABLE VALUES (%s, %s)',\n [('one', 'two'), ('three', 'four')])\n # Untraced command\n cursor.callproc('MyStoredProcedure')\n tracing.commit()\n\nTrace All Connection Commands (implicit ``commit()`` and ``rollback()``)\n------------------------------------------------------------------------\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n tracing = ConnectionTracing(connection, opentracing_tracer)\n\n with tracing as cursor: # If DB API client supports Connection as context manager\n cursor.execute('SELECT * FROM TABLE')\n vals = cursor.fetchall()\n cursor.executemany('INSERT INTO TABLE VALUES (%s, %s)',\n [('one', 'two'), ('three', 'four')])\n cursor.callproc('MyStoredProcedure')\n\nTrace Specific Connection Command Types\n---------------------------------------\n\n.. code-block:: python\n\n from dbapi_opentracing import ConnectionTracing\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n # Provide False values for optional trace_execute, trace_executemany, trace_callproc, trace_commit,\n # and/or trace_rollback named arguments\n tracing = ConnectionTracing(connection, opentracing_tracer, trace_execute=False, trace_commit=False)\n\n with tracing as cursor: # If DB API client supports Connection as context manager\n # Untraced query\n cursor.execute('SELECT * FROM TABLE')\n vals = cursor.fetchall()\n # Traced command\n cursor.executemany('INSERT INTO TABLE VALUES (%s, %s)',\n [('one', 'two'), ('three', 'four')])\n # Traced command\n cursor.callproc('MyStoredProcedure')\n # Implicit commit() is not traced because of named argument value\n\nTrace Individual Commands Without Named Arguments\n-------------------------------------------------\n\n.. code-block:: python\n\n from dbapi_opentracing import Cursor\n import db_api_compatible_client\n\n opentracing_tracer = ## some OpenTracing tracer implementation\n connection = db_api_compatible_client.connect(...)\n\n with connection.cursor() as cursor:\n # Traced query\n Cursor(cursor, opentracing_tracer).execute('SELECT * FROM TABLE_ONE') \n # Traced query using opentracing.tracer default\n Cursor(cursor).execute('SELECT * FROM TABLE_TWO') \n # Traced query with custom tags\n Cursor(cursor, span_tags={'Query': 'Tag', 'Another': 'Tag'}).execute('SELECT * FROM TABLE_THREE')\n # Untraced command by using unmodified cursor instance\n cursor.executemany('INSERT INTO TABLE VALUES (%s, %s)',\n [('one', 'two'), ('three', 'four')])\n\nFurther Information\n===================\n\nIf you're interested in learning more about the OpenTracing standard, please visit\n`opentracing.io`_ or `join the mailing list`_. If you would like to implement OpenTracing\nin your project and need help, feel free to send us a note at `community@opentracing.io`_.\n\n.. _opentracing.io: http://opentracing.io/\n.. _join the mailing list: http://opentracing.us13.list-manage.com/subscribe?u=180afe03860541dae59e84153&id=19117aa6cd\n.. _community@opentracing.io: community@opentracing.io", "description_content_type": "", "docs_url": null, "download_url": "http://github.com/opentracing-contrib/python-dbapi/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/opentracing-contrib/python-dbapi", "keywords": "", "license": "Apache Software License v2", "maintainer": "", "maintainer_email": "", "name": "DBAPI-OpenTracing", "package_url": "https://pypi.org/project/DBAPI-OpenTracing/", "platform": "any", "project_url": "https://pypi.org/project/DBAPI-OpenTracing/", "project_urls": { "Download": "http://github.com/opentracing-contrib/python-dbapi/tarball/master", "Homepage": "http://github.com/opentracing-contrib/python-dbapi" }, "release_url": "https://pypi.org/project/DBAPI-OpenTracing/0.0.4/", "requires_dist": null, "requires_python": "", "summary": "OpenTracing support for Python DB API", "version": "0.0.4" }, "last_serial": 5512348, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "3f6ff502a3d40b19e0def9041b16c7a2", "sha256": "d6719c4cb9e066eeb19f22b983f80d2610b964754470048bacdc59d3af50641d" }, "downloads": -1, "filename": "DBAPI-OpenTracing-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3f6ff502a3d40b19e0def9041b16c7a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4757, "upload_time": "2018-12-13T19:32:06", "url": "https://files.pythonhosted.org/packages/ff/5b/5f84c8aa2dd7dd877220aee263ad7c7bce0e31febe934b0555868c8f8d65/DBAPI-OpenTracing-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "c54542027db7576a31aec48353bfadd1", "sha256": "68ded7b3102d82ea53247f053db6c4f04a953a0604a64655e12699e2de5946ed" }, "downloads": -1, "filename": "DBAPI-OpenTracing-0.0.2.tar.gz", "has_sig": false, "md5_digest": "c54542027db7576a31aec48353bfadd1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5826, "upload_time": "2019-01-03T23:53:06", "url": "https://files.pythonhosted.org/packages/5a/92/bec571f129602cbdc2ff0ed497e0d3364cf619ec153615bdbb751d0a12e3/DBAPI-OpenTracing-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "192be38297c40e49c68c9492fcfb8dbf", "sha256": "e3e47c8322a54cd4f4103c076fb86b7d908a240379739e518a78154f560d6af3" }, "downloads": -1, "filename": "DBAPI-OpenTracing-0.0.3.tar.gz", "has_sig": false, "md5_digest": "192be38297c40e49c68c9492fcfb8dbf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10140, "upload_time": "2019-03-21T19:35:18", "url": "https://files.pythonhosted.org/packages/53/b8/1475bacdd954f185f1d2dd52149b55d22a9db649cd0ffc39eeef76e7272f/DBAPI-OpenTracing-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "45f837484fe7c597eee4beb4bf9484a4", "sha256": "91024564d5b766e5b814747afad43501a7016b6131df63b8b1d2f1f0780ef7ad" }, "downloads": -1, "filename": "DBAPI-OpenTracing-0.0.4.tar.gz", "has_sig": false, "md5_digest": "45f837484fe7c597eee4beb4bf9484a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10288, "upload_time": "2019-07-10T14:14:17", "url": "https://files.pythonhosted.org/packages/e4/38/f5d537cb07c4b204a8d7438a729171edefb2c278775cf9cf766079ebe6e1/DBAPI-OpenTracing-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "45f837484fe7c597eee4beb4bf9484a4", "sha256": "91024564d5b766e5b814747afad43501a7016b6131df63b8b1d2f1f0780ef7ad" }, "downloads": -1, "filename": "DBAPI-OpenTracing-0.0.4.tar.gz", "has_sig": false, "md5_digest": "45f837484fe7c597eee4beb4bf9484a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10288, "upload_time": "2019-07-10T14:14:17", "url": "https://files.pythonhosted.org/packages/e4/38/f5d537cb07c4b204a8d7438a729171edefb2c278775cf9cf766079ebe6e1/DBAPI-OpenTracing-0.0.4.tar.gz" } ] }