Skip to content

Commit d30d52d

Browse files
committed
Merge branch 'master' into sentry-sdk-2.0
2 parents cd8c5e0 + c53fbac commit d30d52d

9 files changed

Lines changed: 48 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 1.40.4
4+
5+
### Various fixes & improvements
6+
7+
- Only start metrics flusher thread on demand (#2727) by @sentrivana
8+
- Bump checkouts/data-schemas from `aa7058c` to `6121fd3` (#2724) by @dependabot
9+
10+
## 1.40.3
11+
12+
### Various fixes & improvements
13+
14+
- Turn off metrics for uWSGI (#2720) by @sentrivana
15+
- Minor improvements (#2714) by @antonpirker
16+
317
## 1.40.2
418

519
### Various fixes & improvements

checkouts/data-schemas

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
copyright = "2019-{}, Sentry Team and Contributors".format(datetime.now().year)
2929
author = "Sentry Team and Contributors"
3030

31-
release = "1.40.2"
31+
release = "1.40.4"
3232
version = ".".join(release.split(".")[:2]) # The short X.Y version.
3333

3434

sentry_sdk/client.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,28 @@ def _capture_envelope(envelope):
229229

230230
self.metrics_aggregator = None # type: Optional[MetricsAggregator]
231231
experiments = self.options.get("_experiments", {})
232-
if experiments.get("enable_metrics", True):
233-
from sentry_sdk.metrics import MetricsAggregator
234-
235-
self.metrics_aggregator = MetricsAggregator(
236-
capture_func=_capture_envelope,
237-
enable_code_locations=bool(
238-
experiments.get("metric_code_locations", True)
239-
),
240-
)
232+
if experiments.get("enable_metrics", True) or experiments.get(
233+
"force_enable_metrics", False
234+
):
235+
try:
236+
import uwsgi # type: ignore
237+
except ImportError:
238+
uwsgi = None
239+
240+
if uwsgi is not None and not experiments.get(
241+
"force_enable_metrics", False
242+
):
243+
logger.warning("Metrics currently not supported with uWSGI.")
244+
245+
else:
246+
from sentry_sdk.metrics import MetricsAggregator
247+
248+
self.metrics_aggregator = MetricsAggregator(
249+
capture_func=_capture_envelope,
250+
enable_code_locations=bool(
251+
experiments.get("metric_code_locations", True)
252+
),
253+
)
241254

242255
max_request_body_size = ("always", "never", "small", "medium")
243256
if self.options["max_request_body_size"] not in max_request_body_size:

sentry_sdk/consts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class EndpointType(Enum):
5959
"transport_zlib_compression_level": Optional[int],
6060
"transport_num_pools": Optional[int],
6161
"enable_metrics": Optional[bool],
62+
"force_enable_metrics": Optional[bool],
6263
"metrics_summary_sample_rate": Optional[float],
6364
"should_summarize_metric": Optional[Callable[[str, MetricTags], bool]],
6465
"before_emit_metric": Optional[Callable[[str, MetricTags], bool]],
@@ -329,4 +330,4 @@ def _get_default_options():
329330
del _get_default_options
330331

331332

332-
VERSION = "1.40.2"
333+
VERSION = "1.40.4"

sentry_sdk/metrics.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ def __init__(
437437

438438
self._flusher = None # type: Optional[Union[threading.Thread, ThreadPool]]
439439
self._flusher_pid = None # type: Optional[int]
440-
self._ensure_thread()
441440

442441
def _ensure_thread(self):
443442
# type: (...) -> bool
@@ -452,6 +451,11 @@ def _ensure_thread(self):
452451
return True
453452

454453
with self._lock:
454+
# Recheck to make sure another thread didn't get here and start the
455+
# the flusher in the meantime
456+
if self._flusher_pid == pid:
457+
return True
458+
455459
self._flusher_pid = pid
456460

457461
if not is_gevent():
@@ -476,9 +480,9 @@ def _flush_loop(self):
476480
# type: (...) -> None
477481
_in_metrics.set(True)
478482
while self._running or self._force_flush:
479-
self._flush()
480483
if self._running:
481484
self._flush_event.wait(self.FLUSHER_SLEEP_TIME)
485+
self._flush()
482486

483487
def _flush(self):
484488
# type: (...) -> None

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_file_text(file_name):
2121

2222
setup(
2323
name="sentry-sdk",
24-
version="1.40.2",
24+
version="1.40.4",
2525
author="Sentry Team and Contributors",
2626
author_email="hello@sentry.io",
2727
url="https://github.com/getsentry/sentry-python",

tests/integrations/aws_lambda/test_aws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ def lambda_client():
139139

140140
@pytest.fixture(
141141
params=[
142-
"python3.7",
143142
"python3.8",
144143
"python3.9",
145144
"python3.10",
146145
"python3.11",
146+
"python3.12",
147147
]
148148
)
149149
def lambda_runtime(request):

tests/test_metrics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ def test_timing_basic(sentry_init, capture_envelopes, maybe_monkeypatched_thread
264264
metrics.timing("timing", 3.0, tags={"a": "b"}, timestamp=ts)
265265
Hub.current.flush()
266266

267-
(envelope,) = envelopes
268267
(envelope,) = envelopes
269268
statsd_item, meta_item = envelope.items
270269

0 commit comments

Comments
 (0)