@@ -56,7 +56,7 @@ def read_client_metadata() -> ClientMetadata:
5656 session_id = get_session_id (),
5757 machine_id = get_machine_id (),
5858 api_key = get_api_key_or_auth_token () or "" , # api key should not be None
59- system = get_system (),
59+ system = get_system_information_summary (),
6060 version = get_version_string (),
6161 is_ci = os .getenv ("CI" ) is not None ,
6262 is_docker = config .is_in_docker ,
@@ -215,6 +215,7 @@ def get_api_key_or_auth_token() -> str | None:
215215
216216@singleton_factory
217217def get_system () -> str :
218+ # TODO: candidate for removal
218219 try :
219220 # try to get the system from the docker socket
220221 from localstack .utils .docker_utils import DOCKER_CLIENT
@@ -231,6 +232,69 @@ def get_system() -> str:
231232 return platform .system ().lower ()
232233
233234
235+ @singleton_factory
236+ def get_system_information_summary () -> str :
237+ """
238+ Returns a string that contains three comma-separated values: The operating system, kernel version,
239+ and architecture. We either use the docker socket to resolve the information, if that is not available
240+ we fall back ``platform.uname()``. If we're in docker and we don't have the docker socket available,
241+ we add ``(Container)`` to the operating system type to indicate that we don't have any additional
242+ information.
243+
244+ Some examples:
245+
246+ If the Docker socket is available:
247+ - Docker Desktop,5.15.90.1-microsoft-standard-WSL2,x86_64
248+ - Linux Mint 21.1,5.19.0-32-generic,x86_64
249+
250+ If the Docker socket is not available, and we're on the host:
251+ - Windows,10,AMD64
252+ - Linux,5.19.0-32-generic,x86_64
253+
254+ If the Docker socket is not available, and we're in the container:
255+ - Linux(Container),5.19.0-32-generic,x86_64
256+
257+ :return: A string representing the system's information
258+ """
259+ try :
260+ # try to get the system from the docker socket
261+ from localstack .utils .docker_utils import DOCKER_CLIENT
262+
263+ system = DOCKER_CLIENT .get_system_info ()
264+
265+ return "," .join (
266+ [
267+ system ["OperatingSystem" ],
268+ system ["KernelVersion" ],
269+ system ["Architecture" ],
270+ ]
271+ )
272+ except Exception :
273+ if config .DEBUG_ANALYTICS :
274+ LOG .exception (
275+ "Unable to get system information from docker socket, falling back to platform.uname()"
276+ )
277+
278+ uname = platform .uname ()
279+
280+ if config .is_in_docker :
281+ return "," .join (
282+ [
283+ f"{ uname .system } (Container)" ,
284+ uname .release ,
285+ uname .machine ,
286+ ]
287+ )
288+
289+ return "," .join (
290+ [
291+ uname .system ,
292+ uname .release ,
293+ uname .machine ,
294+ ]
295+ )
296+
297+
234298@hooks .prepare_host ()
235299def prepare_host_machine_id ():
236300 # lazy-init machine ID into cache on the host, which can then be used in the container
0 commit comments