Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8508c24
replace utcnow calls
clr182 Nov 5, 2024
fd9b285
conditionally add pkg_resources
clr182 Nov 11, 2024
09c0f41
update changelog
clr182 Nov 11, 2024
c55bb0a
Add v3.13 to test matrices
Cawllec Dec 5, 2024
0977085
Skip python 3.13 in celery 4 tests
Cawllec Dec 5, 2024
145b796
Update tox.ini for 3.13 tests
Cawllec Dec 12, 2024
f5e0236
Push lint to the latest version and stop using yanked packages
Cawllec Dec 12, 2024
b240e80
Merge pull request #395 from bugsnag/tests/3.13-tests
Cawllec Dec 12, 2024
ed8ad0e
Merge branch 'next' into utcnow-deprecated
tomlongridge Dec 13, 2024
d1e1130
test: remove gemfile lock
tomlongridge Dec 13, 2024
5a6036a
Ensure Python 3.7 tests are run on an older ubuntu version
Cawllec Dec 18, 2024
9fd6a13
Merge pull request #396 from bugsnag/tom/remove-gem-lock
Cawllec Dec 18, 2024
55e52dd
Merge pull request #394 from bugsnag/utcnow-deprecated
clr182 Jan 13, 2025
699ea17
Remove license checker (failing to detect valid licenses)
Jun 18, 2025
265c44b
Ignore IntelliJ module files
Jun 18, 2025
283a1ea
Bump runners - Ubuntu 20 no longer available
Jun 18, 2025
9404697
Skip test pending further investigation
Jun 18, 2025
015d419
Skip unit/integration tests with Python 3.5/3.6
Jun 18, 2025
8940cb6
Merge pull request #398 from bugsnag/tms/fix-ci
twometresteve Jun 19, 2025
bffdb66
WIP
Jun 19, 2025
8e7508c
Only default endpoints if not already set
Jun 19, 2025
e5b0227
Fix linter errors
Jun 19, 2025
2fae759
5 space indent
Jun 19, 2025
654734f
4 space indent
Jun 19, 2025
794a089
bracket on new line
Jun 19, 2025
0b44ee0
Unit tests added
Jun 20, 2025
46a749c
Do not configure Client when initialised for singleton clients
Jun 20, 2025
39ad79e
Merge pull request #399 from bugsnag/tms/hub-api-key
twometresteve Jun 24, 2025
1e09d28
Release v4.8.0
Jul 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .github/workflows/license-audit.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/maze-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v4
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
os: ['ubuntu-latest']
include:
- python-version: '3.5'
os: 'ubuntu-20.04'
pip-trusted-host: 'pypi.python.org pypi.org files.pythonhosted.org'
- python-version: '3.6'
os: 'ubuntu-20.04'
# Python 3.5 and 3.6 tests skipped pending PLAT-14414
# - python-version: '3.5'
# os: 'ubuntu-22.04'
# pip-trusted-host: 'pypi.python.org pypi.org files.pythonhosted.org'
# - python-version: '3.6'
# os: 'ubuntu-22.04'
- python-version: '3.7'
os: 'ubuntu-22.04'

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.aws-sam
maze-runner.log
maze_output
Gemfile.lock

*.py[co]

Expand Down Expand Up @@ -37,3 +38,4 @@ htmlcov
my_env
venv
.idea
*.iml
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

## v4.8.0 (2024-07-08)

### Enhancements

* Remove deprecated `datetime.utcnow()` method call from utils class
[#394](https://github.com/bugsnag/bugsnag-python/pull/394).
* Set default endpoints based on API key
[#399](https://github.com/bugsnag/bugsnag-php/pull/399)

## v4.7.1 (2024-05-22)

### Bug fixes
Expand Down
143 changes: 0 additions & 143 deletions Gemfile.lock

This file was deleted.

5 changes: 3 additions & 2 deletions bugsnag/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class Client:
"""

def __init__(self, configuration: Optional[Configuration] = None,
install_sys_hook=True, **kwargs):
install_sys_hook=True, configure=True, **kwargs):
self.configuration = configuration or Configuration() # type: Configuration # noqa: E501
self.session_tracker = SessionTracker(self.configuration)
self.configuration.configure(**kwargs)
if configure:
self.configuration.configure(**kwargs)
self._context = ContextLocalState(self)
self._request_tracker = RequestTracker()

Expand Down
47 changes: 37 additions & 10 deletions bugsnag/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
validate_int_setter,
validate_path_setter
)
from bugsnag.delivery import (create_default_delivery, DEFAULT_ENDPOINT,
DEFAULT_SESSIONS_ENDPOINT)
from bugsnag.delivery import (create_default_delivery,
DEFAULT_ENDPOINT,
DEFAULT_SESSIONS_ENDPOINT,
HUB_ENDPOINT,
HUB_SESSIONS_ENDPOINT)
from bugsnag.uwsgi import warn_if_running_uwsgi_without_threads
from bugsnag.error import Error

Expand All @@ -55,6 +58,11 @@
_sentinel = object()


def _is_hub_api_key(api_key: str) -> bool:
hub_prefix = "00000"
return api_key is not None and api_key.startswith(hub_prefix)


class Configuration:
"""
Global app-level Bugsnag configuration settings.
Expand Down Expand Up @@ -83,8 +91,8 @@ def __init__(self, logger=_sentinel):
"django.http.Http404",
"django.http.response.Http404",
]
self.endpoint = DEFAULT_ENDPOINT
self.session_endpoint = DEFAULT_SESSIONS_ENDPOINT
self.endpoint = None
self.session_endpoint = None
self.auto_capture_sessions = True
self.traceback_exclude_modules = []

Expand Down Expand Up @@ -126,8 +134,6 @@ def configure(self, api_key=None, app_type=None, app_version=None,
Validate and set configuration options. Will warn if an option is of an
incorrect type.
"""
if api_key is not None:
self.api_key = api_key
if app_type is not None:
self.app_type = app_type
if app_version is not None:
Expand All @@ -140,8 +146,6 @@ def configure(self, api_key=None, app_type=None, app_version=None,
self.auto_capture_sessions = auto_capture_sessions
if delivery is not None:
self.delivery = delivery
if endpoint is not None:
self.endpoint = endpoint
if hostname is not None:
self.hostname = hostname
if ignore_classes is not None:
Expand All @@ -162,8 +166,6 @@ def configure(self, api_key=None, app_type=None, app_version=None,
self.send_code = send_code
if send_environment is not None:
self.send_environment = send_environment
if session_endpoint is not None:
self.session_endpoint = session_endpoint
if traceback_exclude_modules is not None:
self.traceback_exclude_modules = traceback_exclude_modules
if logger is not _sentinel:
Expand All @@ -175,6 +177,11 @@ def configure(self, api_key=None, app_type=None, app_version=None,
if max_breadcrumbs is not None:
self.max_breadcrumbs = max_breadcrumbs

# Default endpoints depend on the API key
if api_key is not None:
self.api_key = api_key
self._initialize_endpoints(endpoint, session_endpoint, self.api_key)

return self

def get(self, name):
Expand Down Expand Up @@ -584,6 +591,26 @@ def _create_null_logger(self) -> logging.Logger:

return logger

def _initialize_endpoints(self, endpoint, session_endpoint, api_key):
# Default endpoints depending on the API key, if not already set
if (
endpoint is None and
session_endpoint is None and
self.endpoint is None and
self.session_endpoint is None
):
if _is_hub_api_key(api_key):
self.endpoint = HUB_ENDPOINT
self.session_endpoint = HUB_SESSIONS_ENDPOINT
else:
self.endpoint = DEFAULT_ENDPOINT
self.session_endpoint = DEFAULT_SESSIONS_ENDPOINT
# Do set endpoints if explicitly provided
if endpoint is not None:
self.endpoint = endpoint
if session_endpoint is not None:
self.session_endpoint = session_endpoint


class RequestConfiguration:
"""
Expand Down
8 changes: 6 additions & 2 deletions bugsnag/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

DEFAULT_ENDPOINT = 'https://notify.bugsnag.com'
DEFAULT_SESSIONS_ENDPOINT = 'https://sessions.bugsnag.com'
HUB_ENDPOINT = 'https://notify.insighthub.smartbear.com'
HUB_SESSIONS_ENDPOINT = 'https://sessions.insighthub.smartbear.com'

__all__ = ('default_headers', 'Delivery')

Expand Down Expand Up @@ -82,8 +84,10 @@ def deliver_sessions(self, config, payload: Any, options=None):
"""
Sends sessions to Bugsnag
"""
if (config.endpoint != DEFAULT_ENDPOINT and config.session_endpoint ==
DEFAULT_SESSIONS_ENDPOINT):
if ((config.endpoint != DEFAULT_ENDPOINT and
config.session_endpoint == DEFAULT_SESSIONS_ENDPOINT) or
(config.endpoint != HUB_ENDPOINT and
config.session_endpoint == HUB_SESSIONS_ENDPOINT)):
if not self.sent_session_warning:
warnings.warn('The session endpoint has not been configured. '
'No sessions will be sent to Bugsnag.')
Expand Down
2 changes: 1 addition & 1 deletion bugsnag/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from bugsnag.configuration import RequestConfiguration
from bugsnag.client import Client

default_client = Client()
default_client = Client(configure=False)
configuration = default_client.configuration
logger = configuration.logger
ExcInfoType = Tuple[Type, Exception, types.TracebackType]
Expand Down
Loading