File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 11import logging
22import os
33
4+ from localstack import config
45from localstack .runtime import hooks
56from localstack .utils .analytics import log
67
@@ -70,3 +71,32 @@ def _publish_config_as_analytics_event():
7071 present_env_vars = {env_var : 1 for env_var in PRESENCE_ENV_VAR if os .getenv (env_var )}
7172
7273 log .event ("config" , env_vars = env_vars , set_vars = present_env_vars )
74+
75+
76+ class LocalstackContainerInfo :
77+ def get_image_variant (self ) -> str :
78+ for f in os .listdir ("/usr/lib/localstack" ):
79+ if f .startswith ("." ) and f .endswith ("-version" ):
80+ return f [1 :- 8 ]
81+ return "unknown"
82+
83+ def has_docker_socket (self ) -> bool :
84+ return os .path .exists ("/run/docker.sock" )
85+
86+ def to_dict (self ):
87+ return {
88+ "variant" : self .get_image_variant (),
89+ "has_docker_socket" : self .has_docker_socket (),
90+ }
91+
92+
93+ @hooks .on_infra_start ()
94+ def _publish_container_info ():
95+ if not config .is_in_docker :
96+ return
97+
98+ try :
99+ log .event ("container_info" , payload = LocalstackContainerInfo ().to_dict ())
100+ except Exception as e :
101+ if config .DEBUG_ANALYTICS :
102+ LOG .debug ("error gathering container information: %s" , e )
You can’t perform that action at this time.
0 commit comments