()
| 159 | |
| 160 | |
| 161 | def _metadata_env() -> dict[str, Any]: |
| 162 | env: dict[str, Any] = {} |
| 163 | container = get_container_env_info() |
| 164 | if container: |
| 165 | env["container"] = container |
| 166 | # Skip if multiple (or no) envs are matched. |
| 167 | if (_is_lambda(), _is_azure_func(), _is_gcp_func(), _is_vercel()).count(True) != 1: |
| 168 | return env |
| 169 | if _is_lambda(): |
| 170 | env["name"] = "aws.lambda" |
| 171 | region = os.getenv("AWS_REGION") |
| 172 | if region: |
| 173 | env["region"] = region |
| 174 | memory_mb = _getenv_int("AWS_LAMBDA_FUNCTION_MEMORY_SIZE") |
| 175 | if memory_mb is not None: |
| 176 | env["memory_mb"] = memory_mb |
| 177 | elif _is_azure_func(): |
| 178 | env["name"] = "azure.func" |
| 179 | elif _is_gcp_func(): |
| 180 | env["name"] = "gcp.func" |
| 181 | region = os.getenv("FUNCTION_REGION") |
| 182 | if region: |
| 183 | env["region"] = region |
| 184 | memory_mb = _getenv_int("FUNCTION_MEMORY_MB") |
| 185 | if memory_mb is not None: |
| 186 | env["memory_mb"] = memory_mb |
| 187 | timeout_sec = _getenv_int("FUNCTION_TIMEOUT_SEC") |
| 188 | if timeout_sec is not None: |
| 189 | env["timeout_sec"] = timeout_sec |
| 190 | elif _is_vercel(): |
| 191 | env["name"] = "vercel" |
| 192 | region = os.getenv("VERCEL_REGION") |
| 193 | if region: |
| 194 | env["region"] = region |
| 195 | return env |
| 196 | |
| 197 | |
| 198 | _MAX_METADATA_SIZE = 512 |
no test coverage detected