Skip to content

Commit a59fbc9

Browse files
committed
fix: DeprecationWarning: pkg_resources is deprecated as an API.
Signed-off-by: Ferenc Géczi <[email protected]>
1 parent e833571 commit a59fbc9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/instana/collector/helpers/runtime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# (c) Copyright Instana Inc. 2020
33

44
""" Collection helper for the Python runtime """
5+
import importlib.metadata
56
import os
67
import gc
78
import sys
89
import platform
910
import resource
1011
import threading
1112
from types import ModuleType
12-
from pkg_resources import DistributionNotFound, get_distribution
1313

1414
from instana.log import logger
1515
from instana.version import VERSION
@@ -230,8 +230,8 @@ def gather_python_packages(self):
230230
elif "version" in pkg_info:
231231
versions[pkg_name] = self.jsonable(pkg_info["version"])
232232
else:
233-
versions[pkg_name] = get_distribution(pkg_name).version
234-
except DistributionNotFound:
233+
versions[pkg_name] = importlib.metadata.version(pkg_name)
234+
except importlib.metadata.PackageNotFoundError:
235235
pass
236236
except Exception:
237237
logger.debug("gather_python_packages: could not process module: %s", pkg_name)

src/instana/util/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections import defaultdict
77
from urllib import parse
88

9-
import pkg_resources
9+
import importlib.metadata
1010

1111
from ..log import logger
1212

@@ -65,8 +65,8 @@ def package_version():
6565
"""
6666
version = ""
6767
try:
68-
version = pkg_resources.get_distribution('instana').version
69-
except pkg_resources.DistributionNotFound:
68+
version = importlib.metadata.version('instana')
69+
except importlib.metadata.PackageNotFoundError:
7070
version = 'unknown'
7171

7272
return version

0 commit comments

Comments
 (0)