Best Python code snippet using localstack_python
metric_handler.py
Source:metric_handler.py
...106 if not config.is_collect_metrics_mode():107 return108 item = MetricHandlerItem(context)109 self.metrics_handler_items[context] = item110 def _get_metric_handler_item_for_context(self, context: RequestContext) -> MetricHandlerItem:111 return self.metrics_handler_items[context]112 def record_parsed_request(113 self, chain: HandlerChain, context: RequestContext, response: Response114 ):115 if not config.is_collect_metrics_mode():116 return117 item = self._get_metric_handler_item_for_context(context)118 item.parameters_after_parse = (119 list(context.service_request.keys()) if context.service_request else []120 )121 def record_exception(122 self, chain: HandlerChain, exception: Exception, context: RequestContext, response: Response123 ):124 if not config.is_collect_metrics_mode():125 return126 item = self._get_metric_handler_item_for_context(context)127 item.caught_exception_name = exception.__class__.__name__128 def update_metric_collection(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__148 if context.service_exception...
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!!