sentry-arroyo 2.26.0__py3-none-any.whl → 2.28.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ from arroyo.processing.strategies.abstract import (
29
29
  )
30
30
  from arroyo.types import BrokerValue, Message, Partition, Topic, TStrategyPayload
31
31
  from arroyo.utils.logging import handle_internal_error
32
- from arroyo.utils.metrics import get_consumer_metrics
32
+ from arroyo.utils.metrics import get_metrics
33
33
 
34
34
  logger = logging.getLogger(__name__)
35
35
 
@@ -90,7 +90,7 @@ ConsumerCounter = Literal[
90
90
 
91
91
  class MetricsBuffer:
92
92
  def __init__(self) -> None:
93
- self.metrics = get_consumer_metrics()
93
+ self.metrics = get_metrics()
94
94
  self.__timers: MutableMapping[ConsumerTiming, float] = defaultdict(float)
95
95
  self.__counters: MutableMapping[ConsumerCounter, int] = defaultdict(int)
96
96
  self.__reset()
@@ -195,7 +195,6 @@ class StreamProcessor(Generic[TStrategyPayload]):
195
195
  def on_partitions_assigned(partitions: Mapping[Partition, int]) -> None:
196
196
  logger.info("New partitions assigned: %r", partitions)
197
197
  logger.info("Member id: %r", self.__consumer.member_id)
198
- self.__metrics_buffer.metrics.consumer_member_id = self.__consumer.member_id
199
198
 
200
199
  self.__metrics_buffer.metrics.increment(
201
200
  "arroyo.consumer.partitions_assigned.count", len(partitions)
arroyo/utils/metrics.py CHANGED
@@ -45,45 +45,6 @@ class Metrics(Protocol):
45
45
  raise NotImplementedError
46
46
 
47
47
 
48
- class ConsumerMetricsWrapper(Metrics):
49
- """
50
- A wrapper around a metrics backend that automatically adds consumer_member_id
51
- to all metrics calls.
52
-
53
- Right now we only use this to add tags to the metrics emitted by
54
- StreamProcessor, but ideally all metrics, even those emitted by strategies
55
- and application code, would get this tag. The metrics abstraction in arroyo
56
- is not sufficient for this. We'd have to add a "add_global_tags" method
57
- (similar to the concept of global tags in sentry) and users would have to
58
- implement it.
59
- """
60
-
61
- def __init__(self, metrics: Metrics) -> None:
62
- self.__metrics = metrics
63
- self.consumer_member_id = ""
64
-
65
- def _add_consumer_tag(self, tags: Optional[Tags]) -> Tags:
66
- return {**(tags or {}), "consumer_member_id": self.consumer_member_id}
67
-
68
- def increment(
69
- self,
70
- name: MetricName,
71
- value: Union[int, float] = 1,
72
- tags: Optional[Tags] = None,
73
- ) -> None:
74
- self.__metrics.increment(name, value, tags=self._add_consumer_tag(tags))
75
-
76
- def gauge(
77
- self, name: MetricName, value: Union[int, float], tags: Optional[Tags] = None
78
- ) -> None:
79
- self.__metrics.gauge(name, value, tags=self._add_consumer_tag(tags))
80
-
81
- def timing(
82
- self, name: MetricName, value: Union[int, float], tags: Optional[Tags] = None
83
- ) -> None:
84
- self.__metrics.timing(name, value, tags=self._add_consumer_tag(tags))
85
-
86
-
87
48
  class DummyMetricsBackend(Metrics):
88
49
  """
89
50
  Default metrics backend that does not record anything.
@@ -172,12 +133,4 @@ def get_metrics() -> Metrics:
172
133
  return _metrics_backend
173
134
 
174
135
 
175
- def get_consumer_metrics() -> ConsumerMetricsWrapper:
176
- """
177
- Get a metrics backend that automatically adds consumer_member_id to all metrics.
178
- """
179
- base_metrics = get_metrics()
180
- return ConsumerMetricsWrapper(base_metrics)
181
-
182
-
183
- __all__ = ["configure_metrics", "Metrics", "MetricName", "Tags", "get_consumer_metrics"]
136
+ __all__ = ["configure_metrics", "Metrics", "MetricName", "Tags"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sentry-arroyo
3
- Version: 2.26.0
3
+ Version: 2.28.0
4
4
  Summary: Arroyo is a Python library for working with streaming data.
5
5
  Home-page: https://github.com/getsentry/arroyo
6
6
  Author: Sentry
@@ -16,7 +16,7 @@ arroyo/backends/local/storages/__init__.py,sha256=AGYujdAAcn3osoj9jq84IzTywYbkID
16
16
  arroyo/backends/local/storages/abstract.py,sha256=1qVQp6roxHkK6XT2aklZyZk1qq7RzcPN6Db_CA5--kg,2901
17
17
  arroyo/backends/local/storages/memory.py,sha256=AoKDsVZzBXkOJyWArKWp3vfGfU9xLlKFXE9gsJiMIzQ,2613
18
18
  arroyo/processing/__init__.py,sha256=vZVg0wJvJfoVzlzGvnL59bT6YNIRJNQ5t7oU045Qbk4,87
19
- arroyo/processing/processor.py,sha256=PddFijN7uJyNVq1XMBeOSlD1Z0L27kLBplH0X_HF4Kg,21235
19
+ arroyo/processing/processor.py,sha256=CNhybC2nISlja2GoSOWmPnn5_UQin4i07feXWkZCtww,21128
20
20
  arroyo/processing/strategies/__init__.py,sha256=EU_JMb54eOxMxaC5mIFpI-sAF-X2ZScbE8czBZ7bQkY,1106
21
21
  arroyo/processing/strategies/abstract.py,sha256=nu7juEz_aQmQIH35Z8u--FBuLjkK8_LQ1hIG2xpw9AA,4808
22
22
  arroyo/processing/strategies/batching.py,sha256=s89xC6lQpBseEaApu1iNTipXGKeO95OMwinj2VBKn9s,4778
@@ -39,14 +39,14 @@ arroyo/utils/concurrent.py,sha256=dbdPinjqmxCQ7izUGFNbGjB3OxfSIO01bnCSTANaVOE,11
39
39
  arroyo/utils/logging.py,sha256=Y1PnhYcI9XNNEK0H13Ct2xKLr2Niuw0dxayc6sWnui8,606
40
40
  arroyo/utils/metricDefs.json,sha256=5LR4hiHwD9JLaKm8JcpshmVjKCmIZzCxwa5oJxRkzH0,10264
41
41
  arroyo/utils/metric_defs.py,sha256=hZ98tCimeW8W6Gpo_LVvYI4RGtAPRsM6kruf8TtvdEY,7283
42
- arroyo/utils/metrics.py,sha256=UucA2igsosNtjA2L8h8EOkWyjBQNai5H4Vqah6KcgN8,5021
42
+ arroyo/utils/metrics.py,sha256=kcyUR5cacoPMoU80RHSUhTMNzEcMBDpTXzcyW7yWZBk,3308
43
43
  arroyo/utils/profiler.py,sha256=aiYy2RRPX_IiDIO7AnFM3hARaHCctS3rqUS5nrHXbSg,2452
44
44
  arroyo/utils/retries.py,sha256=4MRhHUR7da9x1ytlo7YETo8S9HEebXmPF2-mKP4xYz0,3445
45
45
  examples/transform_and_produce/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  examples/transform_and_produce/batched.py,sha256=st2R6qTneAtV0JFbKP30Ti3sJDYj8Jkbmta9JckKdZU,2636
47
47
  examples/transform_and_produce/script.py,sha256=8kSMIjQNqGYEVyE0PvrfJh-a_UYCrJSstTp_De7kyyg,2306
48
48
  examples/transform_and_produce/simple.py,sha256=H7xqxItjl4tx34wVW5dy6mB9G39QucAtxkJSBzVmjgA,1637
49
- sentry_arroyo-2.26.0.dist-info/licenses/LICENSE,sha256=0Ng3MFdEcnz0sVD1XvGBBzbavvNp_7OAM5yVObB46jU,10829
49
+ sentry_arroyo-2.28.0.dist-info/licenses/LICENSE,sha256=0Ng3MFdEcnz0sVD1XvGBBzbavvNp_7OAM5yVObB46jU,10829
50
50
  tests/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  tests/backends/mixins.py,sha256=sfNyE0VTeiD3GHOnBYl-9urvPuURI2G1BWke0cz7Dvc,20445
52
52
  tests/backends/test_commit.py,sha256=iTHfK1qsBxim0XwxgMvNNSMqDUMEHoYkYBDcgxGBFbs,831
@@ -71,9 +71,9 @@ tests/processing/strategies/test_run_task_with_multiprocessing.py,sha256=eyv3O5X
71
71
  tests/processing/strategies/test_unfold.py,sha256=mbC4XhT6GkJRuC7vPR0h7jqwt4cu20q7Z114EJ6J9mQ,2009
72
72
  tests/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  tests/utils/test_concurrent.py,sha256=Gwdzym2UZ1HO3rhOSGmzxImWcLFygY8P7MXHT3Q0xTE,455
74
- tests/utils/test_metrics.py,sha256=y54LVGIkXok5cNVKKrdCpHmpZ0uJQOefT-PLvqZzjcw,2280
74
+ tests/utils/test_metrics.py,sha256=bI0EtGgPokMQyEqX58i0-8zvLfxRP2nWaWr2wLMaJ_o,917
75
75
  tests/utils/test_retries.py,sha256=AxJLkXWeL9AjHv_p1n0pe8CXXJp24ZQIuYBHfNcmiz4,3075
76
- sentry_arroyo-2.26.0.dist-info/METADATA,sha256=OiWrlIZUPspZgkXQ3UgNef4O8bRi3JfXDgh-Sm6etyk,2208
77
- sentry_arroyo-2.26.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
78
- sentry_arroyo-2.26.0.dist-info/top_level.txt,sha256=DVdMZKysL_iIxm5aY0sYgZtP5ZXMg9YBaBmGQHVmDXA,22
79
- sentry_arroyo-2.26.0.dist-info/RECORD,,
76
+ sentry_arroyo-2.28.0.dist-info/METADATA,sha256=uDigTNOzQ1FZlBfwi995fkSx7EMQKpvQiBJraUVBtMY,2208
77
+ sentry_arroyo-2.28.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
78
+ sentry_arroyo-2.28.0.dist-info/top_level.txt,sha256=DVdMZKysL_iIxm5aY0sYgZtP5ZXMg9YBaBmGQHVmDXA,22
79
+ sentry_arroyo-2.28.0.dist-info/RECORD,,
@@ -1,19 +1,8 @@
1
1
  import pytest
2
2
 
3
- from arroyo.utils.metrics import (
4
- Gauge,
5
- MetricName,
6
- configure_metrics,
7
- get_consumer_metrics,
8
- get_metrics,
9
- )
3
+ from arroyo.utils.metrics import Gauge, MetricName, configure_metrics, get_metrics
10
4
  from tests.metrics import Gauge as GaugeCall
11
- from tests.metrics import (
12
- Increment,
13
- TestingMetricsBackend,
14
- Timing,
15
- _TestingMetricsBackend,
16
- )
5
+ from tests.metrics import TestingMetricsBackend, _TestingMetricsBackend
17
6
 
18
7
 
19
8
  def test_gauge_simple() -> None:
@@ -42,43 +31,3 @@ def test_configure_metrics() -> None:
42
31
  # Can be reset to something else with force
43
32
  configure_metrics(_TestingMetricsBackend(), force=True)
44
33
  assert get_metrics() != TestingMetricsBackend
45
-
46
-
47
- def test_consumer_metrics_wrapper() -> None:
48
- """Test that ConsumerMetricsWrapper automatically adds consumer_member_id to all metrics."""
49
- # Reset to a fresh backend
50
- backend = _TestingMetricsBackend()
51
- configure_metrics(backend, force=True)
52
-
53
- consumer_member_id = "test-consumer-123"
54
- consumer_metrics = get_consumer_metrics()
55
- consumer_metrics.consumer_member_id = consumer_member_id
56
-
57
- # Test increment
58
- consumer_metrics.increment("arroyo.consumer.run.count", 5, tags={"extra": "tag"})
59
-
60
- # Test gauge
61
- consumer_metrics.gauge("arroyo.consumer.librdkafka.total_queue_size", 10.5)
62
-
63
- # Test timing
64
- consumer_metrics.timing("arroyo.consumer.poll.time", 100, tags={"another": "tag"})
65
-
66
- expected_calls = [
67
- Increment(
68
- "arroyo.consumer.run.count",
69
- 5,
70
- {"consumer_member_id": consumer_member_id, "extra": "tag"},
71
- ),
72
- GaugeCall(
73
- "arroyo.consumer.librdkafka.total_queue_size",
74
- 10.5,
75
- {"consumer_member_id": consumer_member_id},
76
- ),
77
- Timing(
78
- "arroyo.consumer.poll.time",
79
- 100,
80
- {"consumer_member_id": consumer_member_id, "another": "tag"},
81
- ),
82
- ]
83
-
84
- assert backend.calls == expected_calls