_settings_types = { 'browser_monitoring.auto_instrument': _setting_boolean, 'instrumentation.templates.inclusion_tag': _setting_set, 'instrumentation.background_task.startup_timeout': float, 'instrumentation.scripts.django_admin': _setting_set, } _settings_defaults = { 'browser_monitoring.auto_instrument': True, 'instrumentation.templates.inclusion_tag': set(), 'instrumentation.background_task.startup_timeout': 10.0, 'instrumentation.scripts.django_admin': set(), } django_settings = extra_settings('import-hook:django', types=_settings_types, defaults=_settings_defaults) def should_ignore(exc, value, tb): from django.http import Http404 if isinstance(value, Http404): if ignore_status_code(404): return True def should_add_browser_timing(response, transaction): # Don't do anything if receive a streaming response which # was introduced in Django 1.5. Need to avoid this as there
def _setting_boolean(value): if value.lower() not in _boolean_states: raise ValueError('Not a boolean: %s' % value) return _boolean_states[value.lower()] _settings_types = { 'browser_monitoring.auto_instrument': _setting_boolean, } _settings_defaults = { 'browser_monitoring.auto_instrument': True, } flask_compress_settings = extra_settings('import-hook:flask_compress', types=_settings_types, defaults=_settings_defaults) def _nr_wrapper_Compress_after_request(wrapped, instance, args, kwargs): def _params(response, *args, **kwargs): return response response = _params(*args, **kwargs) # If the response has direct_passthrough flagged, then is # likely to be streaming a file or other large response. # Leave the response alone in this situation even though # it looked like flask_compress doesn't honour it. if getattr(response, 'direct_passthrough', None):
raise ValueError('Not a boolean: %s' % value) return _boolean_states[value.lower()] _settings_types = { 'debug.transaction_monitoring': _setting_boolean, 'instrumentation.metrics.async_wait_rollup': _setting_boolean, } _settings_defaults = { 'debug.transaction_monitoring': False, 'instrumentation.metrics.async_wait_rollup': True, } tornado_settings = extra_settings('import-hook:tornado', types=_settings_types, defaults=_settings_defaults) _last_transaction_activation = None def last_transaction_activation(): return _last_transaction_activation def record_exception(transaction, exc_info): # Record the details of any exception ignoring status codes which # have been configured to be ignored. import tornado.web