from django.conf import settings

# cache key used to store enabled rulesets.
RULESET_CACHE_KEY = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_KEY', "request_profiler__rulesets")  # noqa
# how long to cache them for - defaults to 10s
RULESET_CACHE_TIMEOUT = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_TIMEOUT', 10)  # noqa

# This is a function that can be used to override all rules to exclude requests from profiling
# e.g. you can use this to ignore staff, or search engine bots, etc.
GLOBAL_EXCLUDE_FUNC = getattr(settings, 'REQUEST_PROFILER_GLOBAL_EXCLUDE_FUNC', lambda r: True)

from django.conf import settings

# cache key used to store enabled rulesets.
RULESET_CACHE_KEY = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_KEY', "request_profiler__rulesets")  # noqa
# how long to cache them for - defaults to 10s
RULESET_CACHE_TIMEOUT = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_TIMEOUT', 10)  # noqa

# This is a function that can be used to override all rules to exclude requests from profiling
# e.g. you can use this to ignore staff, or search engine bots, etc.
GLOBAL_EXCLUDE_FUNC = getattr(
    settings, 'REQUEST_PROFILER_GLOBAL_EXCLUDE_FUNC',
    lambda r: not (hasattr(r, 'user') and r.user.is_staff)
)

Update GLOBAL_EXCLUDE_FUNC default to exclude admins
Update GLOBAL_EXCLUDE_FUNC default to exclude admins

  from django.conf import settings
  
  # cache key used to store enabled rulesets.
  RULESET_CACHE_KEY = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_KEY', "request_profiler__rulesets")  # noqa
  # how long to cache them for - defaults to 10s
  RULESET_CACHE_TIMEOUT = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_TIMEOUT', 10)  # noqa
  
  # This is a function that can be used to override all rules to exclude requests from profiling
  # e.g. you can use this to ignore staff, or search engine bots, etc.
- GLOBAL_EXCLUDE_FUNC = getattr(settings, 'REQUEST_PROFILER_GLOBAL_EXCLUDE_FUNC', lambda r: True)
+ GLOBAL_EXCLUDE_FUNC = getattr(
+     settings, 'REQUEST_PROFILER_GLOBAL_EXCLUDE_FUNC',
+     lambda r: not (hasattr(r, 'user') and r.user.is_staff)
+ )
  
Update GLOBAL_EXCLUDE_FUNC default to exclude admins
## Code Before:
from django.conf import settings

# cache key used to store enabled rulesets.
RULESET_CACHE_KEY = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_KEY', "request_profiler__rulesets")  # noqa
# how long to cache them for - defaults to 10s
RULESET_CACHE_TIMEOUT = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_TIMEOUT', 10)  # noqa

# This is a function that can be used to override all rules to exclude requests from profiling
# e.g. you can use this to ignore staff, or search engine bots, etc.
GLOBAL_EXCLUDE_FUNC = getattr(settings, 'REQUEST_PROFILER_GLOBAL_EXCLUDE_FUNC', lambda r: True)

## Instruction:
Update GLOBAL_EXCLUDE_FUNC default to exclude admins
## Code After:
from django.conf import settings

# cache key used to store enabled rulesets.
RULESET_CACHE_KEY = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_KEY', "request_profiler__rulesets")  # noqa
# how long to cache them for - defaults to 10s
RULESET_CACHE_TIMEOUT = getattr(settings, 'REQUEST_PROFILER_RULESET_CACHE_TIMEOUT', 10)  # noqa

# This is a function that can be used to override all rules to exclude requests from profiling
# e.g. you can use this to ignore staff, or search engine bots, etc.
GLOBAL_EXCLUDE_FUNC = getattr(
    settings, 'REQUEST_PROFILER_GLOBAL_EXCLUDE_FUNC',
    lambda r: not (hasattr(r, 'user') and r.user.is_staff)
)
