Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/checkout…
Browse files Browse the repository at this point in the history
…-4.2.2
  • Loading branch information
sentrivana authored Nov 5, 2024
2 parents d77051c + 5badf77 commit 556b113
Show file tree
Hide file tree
Showing 44 changed files with 676 additions and 39 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ on:
- master
- sentry-sdk-2.0
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
- sentry-sdk-2.0
schedule:
- cron: '18 18 * * 3'

# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/enforce-license-compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ on:
- release/*
- sentry-sdk-2.0
pull_request:
branches:
- master
- main
- sentry-sdk-2.0

# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

jobs:
enforce-license-compliance:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All AI tests passed
name: All pinned AI tests passed
needs: test-ai-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-aws-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All AWS Lambda tests passed
name: All pinned AWS Lambda tests passed
needs: test-aws_lambda-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-cloud-computing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Cloud Computing tests passed
name: All pinned Cloud Computing tests passed
needs: test-cloud_computing-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Common tests passed
name: All pinned Common tests passed
needs: test-common-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-data-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Data Processing tests passed
name: All pinned Data Processing tests passed
needs: test-data_processing-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Databases tests passed
name: All pinned Databases tests passed
needs: test-databases-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All GraphQL tests passed
name: All pinned GraphQL tests passed
needs: test-graphql-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/test-integrations-miscellaneous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ jobs:
- name: Erase coverage
run: |
coverage erase
- name: Test launchdarkly latest
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-launchdarkly-latest"
- name: Test loguru latest
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-loguru-latest"
- name: Test openfeature latest
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-openfeature-latest"
- name: Test opentelemetry latest
run: |
set -x # print commands that are executed
Expand Down Expand Up @@ -117,10 +125,18 @@ jobs:
- name: Erase coverage
run: |
coverage erase
- name: Test launchdarkly pinned
run: |
set -x # print commands that are executed
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-launchdarkly"
- name: Test loguru pinned
run: |
set -x # print commands that are executed
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-loguru"
- name: Test openfeature pinned
run: |
set -x # print commands that are executed
./scripts/runtox.sh --exclude-latest "py${{ matrix.python-version }}-openfeature"
- name: Test opentelemetry pinned
run: |
set -x # print commands that are executed
Expand Down Expand Up @@ -165,7 +181,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Miscellaneous tests passed
name: All pinned Miscellaneous tests passed
needs: test-miscellaneous-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Networking tests passed
name: All pinned Networking tests passed
needs: test-networking-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-web-frameworks-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Web Frameworks 1 tests passed
name: All pinned Web Frameworks 1 tests passed
needs: test-web_frameworks_1-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-web-frameworks-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
files: .junitxml
verbose: true
check_required_tests:
name: All Web Frameworks 2 tests passed
name: All pinned Web Frameworks 2 tests passed
needs: test-web_frameworks_2-pinned
# Always run this, even if a dependent job failed
if: always()
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## 2.18.0

### Various fixes & improvements

- Add LaunchDarkly and OpenFeature integration (#3648) by @cmanallen
- Correct typo in a comment (#3726) by @szokeasaurusrex
- End `http.client` span on timeout (#3723) by @Zylphrex
- Check for `h2` existence in HTTP/2 transport (#3690) by @BYK
- Use `type()` instead when extracting frames (#3716) by @Zylphrex
- Prefer `python_multipart` import over `multipart` (#3710) by @musicinmybrain
- Update active thread for asgi (#3669) by @Zylphrex
- Only enable HTTP2 when DSN is HTTPS (#3678) by @BYK
- Prepare for upstream Strawberry extension removal (#3649) by @DoctorJohn
- Enhance README with improved clarity and developer-friendly examples (#3667) by @UTSAVS26
- Run license compliance action on all PRs (#3699) by @szokeasaurusrex
- Run CodeQL action on all PRs (#3698) by @szokeasaurusrex
- Fix UTC assuming test (#3722) by @BYK
- Exclude fakeredis 2.26.0 on py3.6 and 3.7 (#3695) by @szokeasaurusrex
- Unpin `pytest` for `tornado-latest` tests (#3714) by @szokeasaurusrex
- Install `pytest-asyncio` for `redis` tests (Python 3.12-13) (#3706) by @szokeasaurusrex
- Clarify that only pinned tests are required (#3713) by @szokeasaurusrex
- Remove accidentally-committed print (#3712) by @szokeasaurusrex
- Disable broken RQ test in newly-released RQ 2.0 (#3708) by @szokeasaurusrex
- Unpin `pytest` for `celery` tests (#3701) by @szokeasaurusrex
- Unpin `pytest` on Python 3.8+ `gevent` tests (#3700) by @szokeasaurusrex
- Unpin `pytest` for Python 3.8+ `common` tests (#3697) by @szokeasaurusrex
- Remove `pytest` pin in `requirements-devenv.txt` (#3696) by @szokeasaurusrex
- Test with Falcon 4.0 (#3684) by @sentrivana

## 2.17.0

### Various fixes & improvements
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
author = "Sentry Team and Contributors"

release = "2.17.0"
release = "2.18.0"
version = ".".join(release.split(".")[:2]) # The short X.Y version.


Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-openai.*]
ignore_missing_imports = True
[mypy-openfeature.*]
ignore_missing_imports = True
[mypy-huggingface_hub.*]
ignore_missing_imports = True
[mypy-arq.*]
Expand Down
2 changes: 1 addition & 1 deletion requirements-devenv.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements-linting.txt
-r requirements-testing.txt
mockupdb # required by `pymongo` tests that are enabled by `pymongo` from linter requirements
pytest<7.0.0 # https://github.com/pytest-dev/pytest/issues/9621; see tox.ini
pytest
pytest-asyncio
2 changes: 2 additions & 0 deletions requirements-linting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ flake8-bugbear
pep8-naming
pre-commit # local linting
httpcore
openfeature-sdk
launchdarkly-server-sdk
2 changes: 2 additions & 0 deletions scripts/split-tox-gh-actions/split-tox-gh-actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@
"tornado",
],
"Miscellaneous": [
"launchdarkly",
"loguru",
"openfeature",
"opentelemetry",
"potel",
"pure_eval",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
check_required_tests:
name: All {{ group }} tests passed
name: All pinned {{ group }} tests passed
{% if "pinned" in categories %}
needs: test-{{ group | replace(" ", "_") | lower }}-pinned
{% endif %}
Expand Down
17 changes: 17 additions & 0 deletions sentry_sdk/_lru_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"""

from copy import copy

SENTINEL = object()


Expand Down Expand Up @@ -89,6 +91,13 @@ def __init__(self, max_size):

self.hits = self.misses = 0

def __copy__(self):
cache = LRUCache(self.max_size)
cache.full = self.full
cache.cache = copy(self.cache)
cache.root = copy(self.root)
return cache

def set(self, key, value):
link = self.cache.get(key, SENTINEL)

Expand Down Expand Up @@ -154,3 +163,11 @@ def get(self, key, default=None):
self.hits += 1

return link[VALUE]

def get_all(self):
nodes = []
node = self.root[NEXT]
while node is not self.root:
nodes.append((node[KEY], node[VALUE]))
node = node[NEXT]
return nodes
3 changes: 2 additions & 1 deletion sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CompressionAlgo(Enum):
"Experiments",
{
"max_spans": Optional[int],
"max_flags": Optional[int],
"record_sql_params": Optional[bool],
"continuous_profiling_auto_start": Optional[bool],
"continuous_profiling_mode": Optional[ContinuousProfilerMode],
Expand Down Expand Up @@ -574,4 +575,4 @@ def _get_default_options():
del _get_default_options


VERSION = "2.17.0"
VERSION = "2.18.0"
47 changes: 47 additions & 0 deletions sentry_sdk/flag_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from copy import copy
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk._lru_cache import LRUCache

if TYPE_CHECKING:
from typing import TypedDict, Optional
from sentry_sdk._types import Event, ExcInfo

FlagData = TypedDict("FlagData", {"flag": str, "result": bool})


DEFAULT_FLAG_CAPACITY = 100


class FlagBuffer:

def __init__(self, capacity):
# type: (int) -> None
self.buffer = LRUCache(capacity)
self.capacity = capacity

def clear(self):
# type: () -> None
self.buffer = LRUCache(self.capacity)

def __copy__(self):
# type: () -> FlagBuffer
buffer = FlagBuffer(capacity=self.capacity)
buffer.buffer = copy(self.buffer)
return buffer

def get(self):
# type: () -> list[FlagData]
return [{"flag": key, "result": value} for key, value in self.buffer.get_all()]

def set(self, flag, result):
# type: (str, bool) -> None
self.buffer.set(flag, result)


def flag_error_processor(event, exc_info):
# type: (Event, ExcInfo) -> Optional[Event]
scope = sentry_sdk.get_current_scope()
event["contexts"]["flags"] = {"values": scope.flags.get()}
return event
2 changes: 1 addition & 1 deletion sentry_sdk/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def current(cls):
rv = _local.get(None)
if rv is None:
with _suppress_hub_deprecation_warning():
# This will raise a deprecation warning; supress it since we already warned above.
# This will raise a deprecation warning; suppress it since we already warned above.
rv = Hub(GLOBAL_HUB)
_local.set(rv)
return rv
Expand Down
Loading

0 comments on commit 556b113

Please sign in to comment.