コード例 #1
0
def license_key(args):
    import os
    import sys
    import logging

    if len(args) == 0:
        usage('license-key')
        sys.exit(1)

    from blueware.agent import global_settings, initialize

    if len(args) >= 2:
        log_file = args[1]
    else:
        log_file = '/tmp/python-agent-test.log'

    log_level = logging.DEBUG

    try:
        os.unlink(log_file)
    except Exception:
        pass

    config_file = args[0]
    environment = os.environ.get('BLUEWARE_ENVIRONMENT')

    if config_file == '-':
        config_file = os.environ.get('BLUEWARE_CONFIG_FILE')

    initialize(config_file, environment, ignore_errors=False,
            log_file=log_file, log_level=log_level)

    _settings = global_settings()

    print('license_key = %r' % _settings.license_key)
コード例 #2
0
    def __call__(self, *args, **kwargs):
        transaction = current_transaction()

        settings = global_settings()

        rollup = 'Database/all'

        with FunctionTrace(transaction, callable_name(self.__wrapped__),
                terminal=True, rollup=rollup):
            return self.__connection_wrapper__(self.__wrapped__(
                    *args, **kwargs), self._bw_dbapi2_module, (args, kwargs))
コード例 #3
0
def instrument_django_template_base(module):
    global module_django_template_base
    module_django_template_base = module

    settings = global_settings()

    if 'django.instrumentation.inclusion-tags.r1' in settings.feature_flag:
        wrap_function_wrapper(module, 'generic_tag_compiler',
                _bw_wrapper_django_template_base_generic_tag_compiler_)

        wrap_function_wrapper(module, 'Library.tag',
                _bw_wrapper_django_template_base_Library_tag_)

        wrap_function_wrapper(module, 'Library.inclusion_tag',
                _bw_wrapper_django_template_base_Library_inclusion_tag_)
コード例 #4
0
def instrument_django_template_base(module):
    global module_django_template_base
    module_django_template_base = module

    settings = global_settings()

    if 'django.instrumentation.inclusion-tags.r1' in settings.feature_flag:
        wrap_function_wrapper(
            module, 'generic_tag_compiler',
            _bw_wrapper_django_template_base_generic_tag_compiler_)

        wrap_function_wrapper(module, 'Library.tag',
                              _bw_wrapper_django_template_base_Library_tag_)

        wrap_function_wrapper(
            module, 'Library.inclusion_tag',
            _bw_wrapper_django_template_base_Library_inclusion_tag_)
コード例 #5
0
def network_config(args):
    import os
    import sys
    import logging

    if len(args) == 0:
        usage('network-config')
        sys.exit(1)

    from blueware.agent import global_settings, initialize

    if len(args) >= 2:
        log_file = args[1]
    else:
        log_file = '/tmp/python-agent-test.log'

    log_level = logging.DEBUG

    try:
        os.unlink(log_file)
    except Exception:
        pass

    config_file = args[0]
    environment = os.environ.get('BLUEWARE_ENVIRONMENT')

    if config_file == '-':
        config_file = os.environ.get('BLUEWARE_CONFIG_FILE')

    initialize(config_file,
               environment,
               ignore_errors=False,
               log_file=log_file,
               log_level=log_level)

    _settings = global_settings()

    print('host = %r' % _settings.host)
    print('port = %r' % _settings.port)
    print('proxy_scheme = %r' % _settings.proxy_host)
    print('proxy_host = %r' % _settings.proxy_host)
    print('proxy_port = %r' % _settings.proxy_port)
    print('proxy_user = %r' % _settings.proxy_user)
    print('proxy_pass = %r' % _settings.proxy_pass)
    print('ssl = %r' % _settings.ssl)
コード例 #6
0
ファイル: network_config.py プロジェクト: aadebuger/oneapm
def network_config(args):
    import os
    import sys
    import logging

    if len(args) == 0:
        usage('network-config')
        sys.exit(1)

    from blueware.agent import global_settings, initialize

    if len(args) >= 2:
        log_file = args[1]
    else:
        log_file = '/tmp/python-agent-test.log'

    log_level = logging.DEBUG

    try:
        os.unlink(log_file)
    except Exception:
        pass

    config_file = args[0]
    environment = os.environ.get('BLUEWARE_ENVIRONMENT')

    if config_file == '-':
        config_file = os.environ.get('BLUEWARE_CONFIG_FILE')

    initialize(config_file, environment, ignore_errors=False,
            log_file=log_file, log_level=log_level)

    _settings = global_settings()

    print('host = %r' % _settings.host)
    print('port = %r' % _settings.port)
    print('proxy_scheme = %r' % _settings.proxy_host)
    print('proxy_host = %r' % _settings.proxy_host)
    print('proxy_port = %r' % _settings.proxy_port)
    print('proxy_user = %r' % _settings.proxy_user)
    print('proxy_pass = %r' % _settings.proxy_pass)
    print('ssl = %r' % _settings.ssl)
コード例 #7
0
ファイル: validate_config.py プロジェクト: aadebuger/oneapm
def validate_config(args):
    import os
    import sys
    import logging
    import time

    if len(args) == 0:
        usage('validate-config')
        sys.exit(1)

    from blueware.agent import (global_settings, initialize,
            register_application)

    if len(args) >= 2:
        log_file = args[1]
    else:
        log_file = '/tmp/python-agent-test.log'

    log_level = logging.DEBUG

    try:
        os.unlink(log_file)
    except Exception:
        pass

    config_file = args[0]
    environment = os.environ.get('BLUEWARE_ENVIRONMENT')

    if config_file == '-':
        config_file = os.environ.get('BLUEWARE_CONFIG_FILE')

    initialize(config_file, environment, ignore_errors=False,
            log_file=log_file, log_level=log_level)

    _logger = logging.getLogger(__name__)

    _logger.debug('Starting agent validation.')

    _settings = global_settings()

    app_name = os.environ.get('BLUEWARE_TEST_APP_NAME', 'Python Agent Test')

    _settings.app_name = app_name
    _settings.transaction_tracer.transaction_threshold = 0
    _settings.shutdown_timeout = 30.0

    _settings.debug.log_malformed_json_data = True
    _settings.debug.log_data_collector_payloads = True
    _settings.debug.log_transaction_trace_payload = True

    print(_user_message % dict(app_name=app_name, log_file=log_file))

    _logger.debug('Register test application.')

    _logger.debug('Collector host is %r.', _settings.host)
    _logger.debug('Collector port is %r.', _settings.port)

    _logger.debug('Proxy scheme is %r.', _settings.proxy_scheme)
    _logger.debug('Proxy host is %r.', _settings.proxy_host)
    _logger.debug('Proxy port is %r.', _settings.proxy_port)
    _logger.debug('Proxy user is %r.', _settings.proxy_user)

    _logger.debug('SSL enabled is %r.', _settings.ssl)

    _logger.debug('License key is %r.', _settings.license_key)

    _timeout = 30.0

    _start = time.time()
    _application = register_application(timeout=_timeout)
    _end = time.time()

    _duration = _end - _start

    if not _application.active:
        _logger.error('Unable to register application for test, '
            'connection could not be established within %s seconds.',
            _timeout)
        return

    if hasattr(_application.settings, 'messages'):
        for message in _application.settings.messages:
            if message['message'].startswith('Reporting to:'):
                parts = message['message'].split('Reporting to:')
                url = parts[1].strip()
                print('Registration successful. Reporting to:')
                print()
                print('  %s' % url)
                print()
                break

    _logger.debug('Registration took %s seconds.', _duration)

    _logger.debug('Run the validation test.')

    _run_validation_test()