sonatype-lift[bot] commented on code in PR #211:
URL: https://github.com/apache/skywalking-python/pull/211#discussion_r889065176
##########
skywalking/plugins/sw_psycopg2.py:
##########
@@ -128,3 +128,53 @@ def connect(*args, **kwargs):
_connect = psycopg2.connect
psycopg2.connect = connect
+
+ try: # try to instrument register_type which will fail if it gets a
wrapped cursor or connection
+ from psycopg2._psycopg import register_type as _register_type
+
+ def register_type(c, conn_or_curs):
+ if isinstance(conn_or_curs, ProxyConnection):
+ conn_or_curs = conn_or_curs._self_conn
+ elif isinstance(conn_or_curs, ProxyCursor):
+ conn_or_curs = conn_or_curs._self_cur
+
+ return _register_type(c, conn_or_curs)
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._ipaddress.register_type is _register_type:
+ psycopg2._ipaddress.register_type = register_type
+
+ except Exception:
Review Comment:
*try_except_pass:* Try, Except, Pass detected.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with
`help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=263686957&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=263686957&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686957&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686957&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=263686957&lift_comment_rating=5)
]
##########
skywalking/plugins/sw_psycopg2.py:
##########
@@ -128,3 +128,53 @@ def connect(*args, **kwargs):
_connect = psycopg2.connect
psycopg2.connect = connect
+
+ try: # try to instrument register_type which will fail if it gets a
wrapped cursor or connection
+ from psycopg2._psycopg import register_type as _register_type
+
+ def register_type(c, conn_or_curs):
+ if isinstance(conn_or_curs, ProxyConnection):
+ conn_or_curs = conn_or_curs._self_conn
+ elif isinstance(conn_or_curs, ProxyCursor):
+ conn_or_curs = conn_or_curs._self_cur
+
+ return _register_type(c, conn_or_curs)
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._ipaddress.register_type is _register_type:
+ psycopg2._ipaddress.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._json.register_type is _register_type:
+ psycopg2._json.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._range.register_type is _register_type:
+ psycopg2._range.register_type = register_type
+
+ except Exception:
Review Comment:
*try_except_pass:* Try, Except, Pass detected.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with
`help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=263686959&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=263686959&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686959&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686959&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=263686959&lift_comment_rating=5)
]
##########
skywalking/plugins/sw_psycopg2.py:
##########
@@ -128,3 +128,53 @@ def connect(*args, **kwargs):
_connect = psycopg2.connect
psycopg2.connect = connect
+
+ try: # try to instrument register_type which will fail if it gets a
wrapped cursor or connection
+ from psycopg2._psycopg import register_type as _register_type
+
+ def register_type(c, conn_or_curs):
+ if isinstance(conn_or_curs, ProxyConnection):
+ conn_or_curs = conn_or_curs._self_conn
+ elif isinstance(conn_or_curs, ProxyCursor):
+ conn_or_curs = conn_or_curs._self_cur
+
+ return _register_type(c, conn_or_curs)
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._ipaddress.register_type is _register_type:
+ psycopg2._ipaddress.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._json.register_type is _register_type:
+ psycopg2._json.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._range.register_type is _register_type:
+ psycopg2._range.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2.extensions.register_type is _register_type:
+ psycopg2.extensions.register_type = register_type
+
+ except Exception:
+ pass
+
+ except Exception:
Review Comment:
*try_except_pass:* Try, Except, Pass detected.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with
`help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=263686961&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=263686961&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686961&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686961&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=263686961&lift_comment_rating=5)
]
##########
skywalking/plugins/sw_psycopg2.py:
##########
@@ -128,3 +128,53 @@ def connect(*args, **kwargs):
_connect = psycopg2.connect
psycopg2.connect = connect
+
+ try: # try to instrument register_type which will fail if it gets a
wrapped cursor or connection
+ from psycopg2._psycopg import register_type as _register_type
+
+ def register_type(c, conn_or_curs):
+ if isinstance(conn_or_curs, ProxyConnection):
+ conn_or_curs = conn_or_curs._self_conn
+ elif isinstance(conn_or_curs, ProxyCursor):
+ conn_or_curs = conn_or_curs._self_cur
+
+ return _register_type(c, conn_or_curs)
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._ipaddress.register_type is _register_type:
+ psycopg2._ipaddress.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._json.register_type is _register_type:
+ psycopg2._json.register_type = register_type
+
+ except Exception:
Review Comment:
*try_except_pass:* Try, Except, Pass detected.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with
`help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=263686958&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=263686958&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686958&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686958&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=263686958&lift_comment_rating=5)
]
##########
skywalking/plugins/sw_psycopg2.py:
##########
@@ -128,3 +128,53 @@ def connect(*args, **kwargs):
_connect = psycopg2.connect
psycopg2.connect = connect
+
+ try: # try to instrument register_type which will fail if it gets a
wrapped cursor or connection
+ from psycopg2._psycopg import register_type as _register_type
+
+ def register_type(c, conn_or_curs):
+ if isinstance(conn_or_curs, ProxyConnection):
+ conn_or_curs = conn_or_curs._self_conn
+ elif isinstance(conn_or_curs, ProxyCursor):
+ conn_or_curs = conn_or_curs._self_cur
+
+ return _register_type(c, conn_or_curs)
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._ipaddress.register_type is _register_type:
+ psycopg2._ipaddress.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._json.register_type is _register_type:
+ psycopg2._json.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2._range.register_type is _register_type:
+ psycopg2._range.register_type = register_type
+
+ except Exception:
+ pass
+
+ try:
+ import psycopg2._ipaddress
+
+ if psycopg2.extensions.register_type is _register_type:
+ psycopg2.extensions.register_type = register_type
+
+ except Exception:
Review Comment:
*try_except_pass:* Try, Except, Pass detected.
(at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with
`help` or `ignore`)
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=263686960&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=263686960&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686960&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=263686960&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=263686960&lift_comment_rating=5)
]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]