import os from abc import ABC, abstractmethod from typing import Dict, List, Optional from lumigo_tracer.user_utils import add_execution_tag from lumigo_tracer.parsing_utils import str_to_list from lumigo_tracer.lumigo_utils import get_logger, is_api_gw_event, Configuration AUTO_TAG_API_GW_HEADERS: Optional[List[str]] = (str_to_list( os.environ.get("LUMIGO_AUTO_TAG_API_GW_HEADERS", "")) or []) class EventAutoTagHandler(ABC): """ EventAutoTagHandler API When adding a new handler update the handlers list under AutoTagEvent.auto_tag_event """ @staticmethod @abstractmethod def is_supported(event) -> bool: raise NotImplementedError() @staticmethod @abstractmethod def auto_tag(event) -> Dict: raise NotImplementedError() class ApiGWHandler(EventAutoTagHandler): @staticmethod def is_supported(event) -> bool:
from collections import OrderedDict from typing import Dict, List, Optional from lumigo_tracer.parsing_utils import str_to_list, safe_get from lumigo_tracer.lumigo_utils import ( get_logger, is_api_gw_event, lumigo_dumps, Configuration, should_use_tracer_extension, aws_dump, ) EVENT_MAX_SIZE = 6 * 1024 * 1024 API_GW_KEYS_ORDER = str_to_list(os.environ.get("LUMIGO_API_GW_KEYS_ORDER", "")) or [ "version", "routeKey", "rawPath", "rawQueryString", "resource", "path", "httpMethod", "queryStringParameters", "pathParameters", "body", "requestContext", "headers", ] CLOUDFRONT_KEYS_ORDER = str_to_list(
def test_str_to_list_exception(): assert str_to_list([1]) is None
import copy import os from abc import ABC, abstractmethod from collections import OrderedDict from typing import Dict, List, Optional from lumigo_tracer.parsing_utils import str_to_list, safe_get from lumigo_tracer.lumigo_utils import ( get_logger, is_api_gw_event, lumigo_dumps, Configuration, ) API_GW_KEYS_ORDER = str_to_list(os.environ.get("LUMIGO_API_GW_KEYS_ORDER", "")) or [ "version", "routeKey", "rawPath", "rawQueryString", "resource", "path", "httpMethod", "queryStringParameters", "pathParameters", "body", "requestContext", "headers", ] CLOUDFRONT_KEYS_ORDER = str_to_list(os.environ.get("LUMIGO_CLOUDFRONT_KEYS_ORDER", "")) or [ "config"
def test_str_to_list(): assert str_to_list("a,b,c,d") == ["a", "b", "c", "d"]