44
55import sentry_sdk
66from sentry_sdk .consts import OP , SPANDATA
7- from sentry_sdk .integrations import Integration , DidNotEnable
7+ from sentry_sdk .integrations import _MIN_VERSIONS , Integration , DidNotEnable
88from sentry_sdk .tracing import Span
99from sentry_sdk .tracing_utils import add_query_source , record_sql_queries
1010from sentry_sdk .utils import (
2020except ImportError :
2121 raise DidNotEnable ("asyncpg not installed." )
2222
23- # asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
24- asyncpg_version = parse_version (asyncpg .__version__ )
25-
26- if asyncpg_version is not None and asyncpg_version < (0 , 23 , 0 ):
27- raise DidNotEnable ("asyncpg >= 0.23.0 required" )
28-
2923
3024class AsyncPGIntegration (Integration ):
3125 identifier = "asyncpg"
@@ -37,6 +31,13 @@ def __init__(self, *, record_params: bool = False):
3731
3832 @staticmethod
3933 def setup_once () -> None :
34+ # asyncpg.__version__ is a string containing the semantic version in the form of "<major>.<minor>.<patch>"
35+ asyncpg_version = parse_version (asyncpg .__version__ )
36+
37+ min_version = _MIN_VERSIONS [AsyncPGIntegration .identifier ]
38+ if asyncpg_version is not None and asyncpg_version < min_version :
39+ raise DidNotEnable (f"asyncpg >= { '.' .join (map (str , min_version ))} required" )
40+
4041 asyncpg .Connection .execute = _wrap_execute (
4142 asyncpg .Connection .execute ,
4243 )
0 commit comments