patch.py 文件源码

python
阅读 39 收藏 0 点赞 0 评论 0

项目:dd-trace-py 作者: DataDog 项目源码 文件源码
def patch_conn(conn, traced_conn_cls=dbapi.TracedConnection):
    """ Wrap will patch the instance so that it's queries are traced."""
    # ensure we've patched extensions (this is idempotent) in
    # case we're only tracing some connections.
    _patch_extensions(_psycopg2_extensions)

    c = traced_conn_cls(conn)

    # fetch tags from the dsn
    dsn = sql.parse_pg_dsn(conn.dsn)
    tags = {
        net.TARGET_HOST: dsn.get("host"),
        net.TARGET_PORT: dsn.get("port"),
        db.NAME: dsn.get("dbname"),
        db.USER: dsn.get("user"),
        "db.application" : dsn.get("application_name"),
    }

    Pin(
        service="postgres",
        app="postgres",
        app_type="db",
        tags=tags).onto(c)

    return c
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号