Skip to content

Commit

Permalink
Merge branch 'potel-base' into antonpirker/potel/fix-celery
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Dec 23, 2024
2 parents 5c56b83 + ea4a30e commit 73e333b
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- name: Get auth token
id: token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
with:
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
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 @@ -54,7 +54,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-dbs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-web-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-web-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
coverage xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion scripts/split_tox_gh_actions/templates/test_group.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

- name: Upload coverage to Codecov
if: {% raw %}${{ !cancelled() }}{% endraw %}
uses: codecov/[email protected].1
uses: codecov/[email protected].2
with:
token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %}
files: coverage.xml
Expand Down
9 changes: 0 additions & 9 deletions sentry_sdk/_lru_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ def __init__(self, max_size):
self.hits = self.misses = 0
self.full = False

def __copy__(self):
# type: () -> LRUCache
new = LRUCache(max_size=self.max_size)
new.hits = self.hits
new.misses = self.misses
new.full = self.full
new._data = self._data.copy()
return new

def set(self, key, value):
# type: (Any, Any) -> None
current = self._data.pop(key, _SENTINEL)
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def _prepare_event(

for key in "release", "environment", "server_name", "dist":
if event.get(key) is None and self.options[key] is not None:
event[key] = str(self.options[key]).strip() # type: ignore[literal-required]
event[key] = str(self.options[key]).strip()
if event.get("sdk") is None:
sdk_info = dict(SDK_INFO)
sdk_info["integrations"] = sorted(self.integrations.keys())
Expand Down Expand Up @@ -532,7 +532,7 @@ def _prepare_event(
self.transport.record_lost_event(
"before_send", data_category="error"
)
event = new_event # type: ignore
event = new_event

before_send_transaction = self.options["before_send_transaction"]
if (
Expand Down Expand Up @@ -562,7 +562,7 @@ def _prepare_event(
reason="before_send", data_category="span", quantity=spans_delta
)

event = new_event # type: ignore
event = new_event

return event

Expand Down
7 changes: 0 additions & 7 deletions sentry_sdk/flag_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from copy import copy
from typing import TYPE_CHECKING

import sentry_sdk
Expand All @@ -25,12 +24,6 @@ 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()]
Expand Down
14 changes: 7 additions & 7 deletions sentry_sdk/integrations/launchdarkly.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@

class LaunchDarklyIntegration(Integration):
identifier = "launchdarkly"
_ld_client = None # type: LDClient | None

def __init__(self, ld_client=None):
# type: (LDClient | None) -> None
"""
:param client: An initialized LDClient instance. If a client is not provided, this
integration will attempt to use the shared global instance.
"""
self.__class__._ld_client = ld_client

@staticmethod
def setup_once():
# type: () -> None
try:
client = ld_client or ldclient.get()
client = LaunchDarklyIntegration._ld_client or ldclient.get()
except Exception as exc:
raise DidNotEnable("Error getting LaunchDarkly client. " + repr(exc))

if not client.is_initialized():
raise DidNotEnable("LaunchDarkly client is not initialized.")

# Register the flag collection hook with the LD client.
client.add_hook(LaunchDarklyHook())

@staticmethod
def setup_once():
# type: () -> None
scope = sentry_sdk.get_current_scope()
scope.add_error_processor(flag_error_processor)

Expand Down
10 changes: 5 additions & 5 deletions sentry_sdk/integrations/rust_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@


class RustTracingLevel(Enum):
Trace: str = "TRACE"
Debug: str = "DEBUG"
Info: str = "INFO"
Warn: str = "WARN"
Error: str = "ERROR"
Trace = "TRACE"
Debug = "DEBUG"
Info = "INFO"
Warn = "WARN"
Error = "ERROR"


class EventTypeMapping(Enum):
Expand Down
4 changes: 2 additions & 2 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys
import warnings
from copy import copy
from copy import copy, deepcopy
from collections import deque
from contextlib import contextmanager
from enum import Enum
Expand Down Expand Up @@ -231,7 +231,7 @@ def __copy__(self):

rv._last_event_id = self._last_event_id

rv._flags = copy(self._flags)
rv._flags = deepcopy(self._flags)

return rv

Expand Down
21 changes: 10 additions & 11 deletions tests/integrations/launchdarkly/test_launchdarkly.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,21 @@ async def runner():
}


def test_launchdarkly_integration_did_not_enable(monkeypatch):
# Client is not passed in and set_config wasn't called.
# TODO: Bad practice to access internals like this. We can skip this test, or remove this
# case entirely (force user to pass in a client instance).
def test_launchdarkly_integration_did_not_enable(sentry_init, uninstall_integration):
"""
Setup should fail when using global client and ldclient.set_config wasn't called.
We're accessing ldclient internals to set up this test, so it might break if launchdarkly's
implementation changes.
"""

ldclient._reset_client()
try:
ldclient.__lock.lock()
ldclient.__config = None
finally:
ldclient.__lock.unlock()

uninstall_integration(LaunchDarklyIntegration.identifier)
with pytest.raises(DidNotEnable):
LaunchDarklyIntegration()

# Client not initialized.
client = LDClient(config=Config("sdk-key"))
monkeypatch.setattr(client, "is_initialized", lambda: False)
with pytest.raises(DidNotEnable):
LaunchDarklyIntegration(ld_client=client)
sentry_init(integrations=[LaunchDarklyIntegration()])
Loading

0 comments on commit 73e333b

Please sign in to comment.