示例#1
0
def test_lumigo_dumps_with_omit_skip_and_should_scrub_known_services(
        monkeypatch):
    monkeypatch.setenv("LUMIGO_SCRUB_KNOWN_SERVICES", "true")
    config()

    assert lumigo_dumps({"key": "v"},
                        omit_skip_path=["key"]) == '{"key": "****"}'
示例#2
0
def lumigo_tracer(*args, **kwargs):
    """
    This function should be used as wrapper to your lambda function.
    It will trace your HTTP calls and send it to our backend, which will help you understand it better.

    If the kill switch is activated (env variable `LUMIGO_SWITCH_OFF` set to 1), this function does nothing.

    You can pass to this decorator more configurations to configure the interface to lumigo,
        See `lumigo_tracer.reporter.config` for more details on the available configuration.
    """
    config(*args, **kwargs)
    return _lumigo_tracer
示例#3
0
def start_extension_loop(lambda_service: LambdaService):
    with lumigo_safe_execute("Extension main initialization"):
        get_extension_logger().debug(
            f"Extension started running with extension id: {lambda_service.extension_id}"
        )
        config()
        extension = LumigoExtension(lambda_service)
    for event in lambda_service.events_generator():
        get_extension_logger().debug(f"Extension got event: {event}")
        if event.get("eventType") == "INVOKE":
            with lumigo_safe_execute("Extension: start new invocation"):
                extension.start_new_invocation(event)
        elif event.get("eventType") == "SHUTDOWN":
            with lumigo_safe_execute("Extension: shutdown"):
                extension.shutdown()
            break
        else:
            get_extension_logger().error(f"Extension got unknown event: {event}")
    get_extension_logger().debug("Extension finished running")
示例#4
0
def test_config_timeout_timer_buffer_with_exception(monkeypatch):
    monkeypatch.setenv("LUMIGO_TIMEOUT_BUFFER", "not float")
    config()
    assert Configuration.timeout_timer_buffer is None
示例#5
0
def test_config_lumigo_domains_scrubber_with_envs(monkeypatch):
    monkeypatch.setenv("LUMIGO_DOMAINS_SCRUBBER",
                       '["lambda.us-west-2.amazonaws.com"]')
    config()
    assert len(Configuration.domains_scrubber) == 1
示例#6
0
def test_config_enhanced_printstep_function_without_envs(
        monkeypatch, configuration_value):
    monkeypatch.delenv("LUMIGO_STEP_FUNCTION", raising=False)
    config(step_function=configuration_value)
    assert Configuration.is_step_function == configuration_value
示例#7
0
def test_config_enhanced_printstep_function_with_envs(monkeypatch,
                                                      configuration_value):
    monkeypatch.setenv("LUMIGO_STEP_FUNCTION", "TRUE")
    config(step_function=configuration_value)
    assert Configuration.is_step_function is True
示例#8
0
def test_config_enhanced_print_without_envs(monkeypatch, configuration_value):
    monkeypatch.delenv("LUMIGO_ENHANCED_PRINT", raising=False)
    config(enhance_print=configuration_value)
    assert Configuration.enhanced_print == configuration_value
示例#9
0
def test_config_enhanced_print_with_envs(monkeypatch, configuration_value):
    monkeypatch.setenv("LUMIGO_ENHANCED_PRINT", "TRUE")
    config(enhance_print=configuration_value)
    assert Configuration.enhanced_print is True
示例#10
0
def test_config_lumigo_no_auto_tag_env(monkeypatch):
    monkeypatch.delenv("LUMIGO_AUTO_TAG", raising=False)
    config()
    assert Configuration.auto_tag == [DEFAULT_AUTO_TAG_KEY]
示例#11
0
def test_should_scrub_domain(regexes, url, expected):
    config(domains_scrubber=regexes)
    assert should_scrub_domain(url) == expected
示例#12
0
def test_config_no_verbose_param_and_with_env_verbose_equals_to_false_verbose_is_false(
        monkeypatch):
    monkeypatch.setattr(os, "environ", {"LUMIGO_VERBOSE": "FALSE"})
    config()

    assert Configuration.verbose is False
示例#13
0
def test_config_no_verbose_param_and_no_env_verbose_is_true():
    config()

    assert Configuration.verbose
示例#14
0
def test_config_with_verbose_param_with_no_env_verbose_verbose_is_false():
    config(verbose=False)

    assert Configuration.verbose is False
示例#15
0
def test_config_lumigo_auto_tag_kwarg(monkeypatch):
    monkeypatch.delenv("LUMIGO_AUTO_TAG", raising=False)
    config(auto_tag=["key1", "key2"])
    assert Configuration.auto_tag == ["key1", "key2"]
示例#16
0
def verbose_logger():
    """
    This fixture make sure that we will see all the log in the tests.
    """
    lumigo_utils.get_logger().setLevel(logging.DEBUG)
    lumigo_utils.config(should_report=False, verbose=True)
示例#17
0
def test_config_lumigo_auto_tag(monkeypatch):
    monkeypatch.setenv("LUMIGO_AUTO_TAG", "key1,key2")
    config()
    assert Configuration.auto_tag == ["key1", "key2"]