• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

localstack / localstack / 17366099794

30 Aug 2025 01:41PM UTC coverage: 86.865% (+0.03%) from 86.838%
17366099794

push

github

web-flow
Unit-tests: enable unit-tests for aws handlers (#13070)

67085 of 77229 relevant lines covered (86.87%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.84
/localstack-core/localstack/runtime/analytics.py
1
import logging
1✔
2
import os
1✔
3

4
from localstack import config
1✔
5
from localstack.runtime import hooks
1✔
6
from localstack.utils.analytics import log
1✔
7

8
LOG = logging.getLogger(__name__)
1✔
9

10
TRACKED_ENV_VAR = [
1✔
11
    "ACTIVATE_PRO",
12
    "ALLOW_NONSTANDARD_REGIONS",
13
    "BEDROCK_PREWARM",
14
    "CFN_IGNORE_UNSUPPORTED_RESOURCE_TYPES",
15
    "CLOUDFRONT_LAMBDA_EDGE",
16
    "CONTAINER_RUNTIME",
17
    "DEBUG",
18
    "DEFAULT_REGION",  # Not functional; deprecated in 0.12.7, removed in 3.0.0
19
    "DEFAULT_BEDROCK_MODEL",
20
    "DISABLE_CORS_CHECK",
21
    "DISABLE_CORS_HEADERS",
22
    "DMS_SERVERLESS_DEPROVISIONING_DELAY",
23
    "DMS_SERVERLESS_STATUS_CHANGE_WAITING_TIME",
24
    "DNS_ADDRESS",
25
    "DYNAMODB_ERROR_PROBABILITY",
26
    "DYNAMODB_IN_MEMORY",
27
    "DYNAMODB_REMOVE_EXPIRED_ITEMS",
28
    "EAGER_SERVICE_LOADING",
29
    "EC2_VM_MANAGER",
30
    "ECS_TASK_EXECUTOR",
31
    "EDGE_PORT",
32
    "ENABLE_REPLICATOR",
33
    "ENFORCE_IAM",
34
    "ES_CUSTOM_BACKEND",  # deprecated in 0.14.0, removed in 3.0.0
35
    "ES_MULTI_CLUSTER",  # deprecated in 0.14.0, removed in 3.0.0
36
    "ES_ENDPOINT_STRATEGY",  # deprecated in 0.14.0, removed in 3.0.0
37
    "EVENT_RULE_ENGINE",
38
    "IAM_SOFT_MODE",
39
    "KINESIS_PROVIDER",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
40
    "KINESIS_ERROR_PROBABILITY",
41
    "KMS_PROVIDER",  # defunct since 1.4.0
42
    "LAMBDA_DEBUG_MODE",
43
    "LAMBDA_DOWNLOAD_AWS_LAYERS",
44
    "LAMBDA_EXECUTOR",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
45
    "LAMBDA_STAY_OPEN_MODE",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
46
    "LAMBDA_REMOTE_DOCKER",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
47
    "LAMBDA_CODE_EXTRACT_TIME",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
48
    "LAMBDA_CONTAINER_REGISTRY",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
49
    "LAMBDA_FALLBACK_URL",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
50
    "LAMBDA_FORWARD_URL",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
51
    "LAMBDA_XRAY_INIT",  # Not functional; deprecated in 2.0.0, removed in 3.0.0
52
    "LAMBDA_PREBUILD_IMAGES",
53
    "LAMBDA_RUNTIME_EXECUTOR",
54
    "LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT",
55
    "LEGACY_EDGE_PROXY",  # Not functional; deprecated in 1.0.0, removed in 2.0.0
56
    "LS_LOG",
57
    "LOCALSTACK_K8S_DEPLOYMENT_METHOD",
58
    "MOCK_UNIMPLEMENTED",  # Not functional; deprecated in 1.3.0, removed in 3.0.0
59
    "OPENSEARCH_ENDPOINT_STRATEGY",
60
    "PERSISTENCE",
61
    "PERSISTENCE_SINGLE_FILE",
62
    "PERSIST_ALL",  # defunct since 2.3.2
63
    "PORT_WEB_UI",
64
    "RDS_MYSQL_DOCKER",
65
    "REQUIRE_PRO",
66
    "SERVICES",
67
    "STRICT_SERVICE_LOADING",
68
    "SKIP_INFRA_DOWNLOADS",
69
    "SQS_ENDPOINT_STRATEGY",
70
    "USE_SINGLE_REGION",  # Not functional; deprecated in 0.12.7, removed in 3.0.0
71
    "USE_SSL",
72
]
73

74
PRESENCE_ENV_VAR = [
1✔
75
    "DATA_DIR",
76
    "EDGE_FORWARD_URL",  # Not functional; deprecated in 1.4.0, removed in 3.0.0
77
    "GATEWAY_LISTEN",
78
    "HOSTNAME",
79
    "HOSTNAME_EXTERNAL",
80
    "HOSTNAME_FROM_LAMBDA",
81
    "HOST_TMP_FOLDER",  # Not functional; deprecated in 1.0.0, removed in 2.0.0
82
    "INIT_SCRIPTS_PATH",  # Not functional; deprecated in 1.1.0, removed in 2.0.0
83
    "KUBERNETES_SERVICE_HOST",
84
    "LAMBDA_DEBUG_MODE_CONFIG_PATH",
85
    "LEGACY_DIRECTORIES",  # Not functional; deprecated in 1.1.0, removed in 2.0.0
86
    "LEGACY_INIT_DIR",  # Not functional; deprecated in 1.1.0, removed in 2.0.0
87
    "LOCALSTACK_HOST",
88
    "LOCALSTACK_HOSTNAME",
89
    "OUTBOUND_HTTP_PROXY",
90
    "OUTBOUND_HTTPS_PROXY",
91
    "S3_DIR",
92
    "SFN_MOCK_CONFIG",
93
    "TMPDIR",
94
]
95

96

97
@hooks.on_infra_start()
1✔
98
def _publish_config_as_analytics_event():
1✔
99
    env_vars = list(TRACKED_ENV_VAR)
1✔
100

101
    for key, value in os.environ.items():
1✔
102
        if key.startswith("PROVIDER_OVERRIDE_"):
1✔
103
            env_vars.append(key)
1✔
104
        elif key.startswith("SYNCHRONOUS_") and key.endswith("_EVENTS"):
1✔
105
            # these config variables have been removed with 3.0.0
106
            env_vars.append(key)
×
107

108
    env_vars = {key: os.getenv(key) for key in env_vars}
1✔
109
    present_env_vars = {env_var: 1 for env_var in PRESENCE_ENV_VAR if os.getenv(env_var)}
1✔
110

111
    log.event("config", env_vars=env_vars, set_vars=present_env_vars)
1✔
112

113

114
class LocalstackContainerInfo:
1✔
115
    def get_image_variant(self) -> str:
1✔
116
        for f in os.listdir("/usr/lib/localstack"):
1✔
117
            if f.startswith(".") and f.endswith("-version"):
1✔
118
                return f[1:-8]
1✔
119
        return "unknown"
×
120

121
    def has_docker_socket(self) -> bool:
1✔
122
        return os.path.exists("/run/docker.sock")
1✔
123

124
    def to_dict(self):
1✔
125
        return {
1✔
126
            "variant": self.get_image_variant(),
127
            "has_docker_socket": self.has_docker_socket(),
128
        }
129

130

131
@hooks.on_infra_start()
1✔
132
def _publish_container_info():
1✔
133
    if not config.is_in_docker:
1✔
134
        return
1✔
135

136
    try:
1✔
137
        log.event("container_info", payload=LocalstackContainerInfo().to_dict())
1✔
138
    except Exception as e:
×
139
        if config.DEBUG_ANALYTICS:
×
140
            LOG.debug("error gathering container information: %s", e)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc