X7ROOT File Manager
Current Path:
/opt/hc_python/lib/python3.12/site-packages/sentry_sdk
opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
sentry_sdk
/
📁
..
📄
__init__.py
(1.19 KB)
📁
__pycache__
📄
_compat.py
(3.04 KB)
📄
_init_implementation.py
(2.5 KB)
📄
_log_batcher.py
(4.97 KB)
📄
_lru_cache.py
(1.2 KB)
📄
_queue.py
(10.99 KB)
📄
_types.py
(10.22 KB)
📄
_werkzeug.py
(3.65 KB)
📁
ai
📄
api.py
(11.59 KB)
📄
attachments.py
(3.04 KB)
📄
client.py
(37.14 KB)
📄
consts.py
(39.68 KB)
📁
crons
📄
debug.py
(1019 B)
📄
envelope.py
(10.11 KB)
📄
feature_flags.py
(2.18 KB)
📄
hub.py
(25.07 KB)
📁
integrations
📄
logger.py
(1.62 KB)
📄
metrics.py
(29.21 KB)
📄
monitor.py
(3.62 KB)
📁
profiler
📄
py.typed
(0 B)
📄
scope.py
(61.85 KB)
📄
scrubber.py
(5.92 KB)
📄
serializer.py
(12.78 KB)
📄
session.py
(5.44 KB)
📄
sessions.py
(8.97 KB)
📄
spotlight.py
(8.47 KB)
📄
tracing.py
(46.99 KB)
📄
tracing_utils.py
(28.14 KB)
📄
transport.py
(31.84 KB)
📄
types.py
(1.19 KB)
📄
utils.py
(57.98 KB)
📄
worker.py
(4.36 KB)
Editing: feature_flags.py
import copy import sentry_sdk from sentry_sdk._lru_cache import LRUCache from threading import Lock from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from typing import TypedDict FlagData = TypedDict("FlagData", {"flag": str, "result": bool}) DEFAULT_FLAG_CAPACITY = 100 class FlagBuffer: def __init__(self, capacity): # type: (int) -> None self.capacity = capacity self.lock = Lock() # Buffer is private. The name is mangled to discourage use. If you use this attribute # directly you're on your own! self.__buffer = LRUCache(capacity) def clear(self): # type: () -> None self.__buffer = LRUCache(self.capacity) def __deepcopy__(self, memo): # type: (dict[int, Any]) -> FlagBuffer with self.lock: buffer = FlagBuffer(self.capacity) buffer.__buffer = copy.deepcopy(self.__buffer, memo) return buffer def get(self): # type: () -> list[FlagData] with self.lock: return [ {"flag": key, "result": value} for key, value in self.__buffer.get_all() ] def set(self, flag, result): # type: (str, bool) -> None if isinstance(result, FlagBuffer): # If someone were to insert `self` into `self` this would create a circular dependency # on the lock. This is of course a deadlock. However, this is far outside the expected # usage of this class. We guard against it here for completeness and to document this # expected failure mode. raise ValueError( "FlagBuffer instances can not be inserted into the dictionary." ) with self.lock: self.__buffer.set(flag, result) def add_feature_flag(flag, result): # type: (str, bool) -> None """ Records a flag and its value to be sent on subsequent error events. We recommend you do this on flag evaluations. Flags are buffered per Sentry scope. """ flags = sentry_sdk.get_isolation_scope().flags flags.set(flag, result) span = sentry_sdk.get_current_span() if span: span.set_flag(f"flag.evaluation.{flag}", result)
Upload File
Create Folder