Skip to content

Commit

Permalink
fix: DeprecationWarning: pkg_resources is deprecated as an API.
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Géczi <ferenc.geczi@ibm.com>
  • Loading branch information
Ferenc- committed Jun 13, 2024
1 parent e833571 commit a59fbc9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/instana/collector/helpers/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# (c) Copyright Instana Inc. 2020

""" Collection helper for the Python runtime """
import importlib.metadata
import os
import gc
import sys
import platform
import resource
import threading
from types import ModuleType
from pkg_resources import DistributionNotFound, get_distribution

from instana.log import logger
from instana.version import VERSION
Expand Down Expand Up @@ -230,8 +230,8 @@ def gather_python_packages(self):
elif "version" in pkg_info:
versions[pkg_name] = self.jsonable(pkg_info["version"])
else:
versions[pkg_name] = get_distribution(pkg_name).version
except DistributionNotFound:
versions[pkg_name] = importlib.metadata.version(pkg_name)
except importlib.metadata.PackageNotFoundError:
pass
except Exception:
logger.debug("gather_python_packages: could not process module: %s", pkg_name)
Expand Down
6 changes: 3 additions & 3 deletions src/instana/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import defaultdict
from urllib import parse

import pkg_resources
import importlib.metadata

from ..log import logger

Expand Down Expand Up @@ -65,8 +65,8 @@ def package_version():
"""
version = ""
try:
version = pkg_resources.get_distribution('instana').version
except pkg_resources.DistributionNotFound:
version = importlib.metadata.version('instana')
except importlib.metadata.PackageNotFoundError:
version = 'unknown'

return version
Expand Down

0 comments on commit a59fbc9

Please sign in to comment.