Best Python code snippet using localstack_python
logging.py
Source:logging.py  
...67        return logger68    def _log(self, context: RequestContext, response: Response):69        aws_logger = self.aws_logger70        http_logger = self.http_logger71        is_internal_call = is_internal_call_context(context.request.headers)72        if is_internal_call:73            aws_logger = self.internal_aws_logger74            http_logger = self.internal_http_logger75        if context.operation:76            # log an AWS response77            if context.service_exception:78                aws_logger.info(79                    "AWS %s.%s => %d (%s)",80                    context.service.service_name,81                    context.operation.name,82                    response.status_code,83                    context.service_exception.code,84                    extra={85                        # request...metric_handler.py
Source:metric_handler.py  
...129        self, chain: HandlerChain, context: RequestContext, response: Response130    ):131        if not config.is_collect_metrics_mode() or not context.service_operation:132            return133        is_internal = is_internal_call_context(context.request.headers)134        item = self._get_metric_handler_item_for_context(context)135        # parameters might get changed when dispatched to the service - we use the params stored in136        # parameters_after_parse137        parameters = ",".join(item.parameters_after_parse or [])138        response_data = response.data.decode("utf-8") if response.status_code >= 300 else ""139        MetricHandler.metric_data.append(140            Metric(141                service=context.service_operation.service,142                operation=context.service_operation.operation,143                headers=context.request.headers,144                parameters=parameters,145                response_code=response.status_code,146                response_data=response_data,147                exception=context.service_exception.__class__.__name__...analytics.py
Source:analytics.py  
...22        if response is None or context.operation is None:23            return24        if config.DISABLE_EVENTS:25            return26        if is_internal_call_context(context.request.headers):27            # don't count internal requests28            return29        # this condition will only be true only for the first call, so it makes sense to not acquire the lock every time30        if not self._started:31            with self._mutex:32                if not self._started:33                    self._started = True34                    self.aggregator.start()35        err_type = self._get_err_type(context, response) if response.status_code >= 400 else None36        service_name = context.operation.service_model.service_name37        operation_name = context.operation.name38        self.aggregator.add_request(39            ServiceRequestInfo(40                service_name,...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
