Skip to content

Commit

Permalink
try catch block,
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Orlovsky committed Sep 10, 2024
1 parent 2098a05 commit 878a617
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/lumigo_opentelemetry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,26 @@ def auto_load(_: Any) -> None:

def init() -> Dict[str, Any]:
"""Initialize the Lumigo OpenTelemetry distribution."""
python_version = sys.version_info
# Check if the major version is 3 and the minor version is between 8 and 11
if python_version.major != 3 or not (8 <= python_version.minor <= 11):
logger.warning(
f"Unsupported Python version {python_version.major}.{python_version.minor}; "
"only Python 3.8 to 3.11 are supported."
)
return {}

if str(os.environ.get("LUMIGO_SWITCH_OFF", False)).lower() == "true":
logger.info(
"Lumigo OpenTelemetry distribution disabled via the 'LUMIGO_SWITCH_OFF' environment variable"
)
try:
python_version = sys.version_info
# Check if the major version is 3 and the minor version is between 8 and 11
if python_version.major != 3 or not (8 <= python_version.minor <= 11):
logger.warning(
f"Unsupported Python version {python_version.major}.{python_version.minor}; "
"only Python 3.8 to 3.11 are supported."
)
return {}

if str(os.environ.get("LUMIGO_SWITCH_OFF", False)).lower() == "true":
logger.info(
"Lumigo OpenTelemetry distribution disabled via the 'LUMIGO_SWITCH_OFF' environment variable"
)
return {}

except AttributeError as e: # Catch any issues with accessing sys.version_info
# Log a warning if there is a failure in verifying the Python version
logger.warning("Failed to verify the Python version due to: %s", str(e))
return {}

# Multiple packages are passed to autowrapt in comma-separated form
Expand Down

0 comments on commit 878a617

Please sign in to comment.