|
@@ -18,6 +18,9 @@ from arroyo.processing.strategies.commit import CommitOffsets
|
|
|
from arroyo.processing.strategies.run_task import RunTask
|
|
|
from arroyo.types import BrokerValue, Commit, Message, Partition
|
|
|
from django.db import router, transaction
|
|
|
+from sentry_kafka_schemas import get_codec
|
|
|
+from sentry_kafka_schemas.codecs import ValidationError
|
|
|
+from sentry_kafka_schemas.schema_types.ingest_monitors_v1 import IngestMonitorMessage
|
|
|
from sentry_sdk.tracing import Span, Transaction
|
|
|
|
|
|
from sentry import quotas, ratelimits
|
|
@@ -40,7 +43,7 @@ from sentry.monitors.models import (
|
|
|
MonitorLimitsExceeded,
|
|
|
MonitorType,
|
|
|
)
|
|
|
-from sentry.monitors.types import CheckinItem, CheckinMessage, ClockPulseMessage
|
|
|
+from sentry.monitors.types import CheckinItem
|
|
|
from sentry.monitors.utils import (
|
|
|
get_new_timeout_at,
|
|
|
get_timeout_at,
|
|
@@ -56,6 +59,8 @@ from sentry.utils.outcomes import Outcome, track_outcome
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
+MONITOR_CODEC = get_codec("ingest-monitors")
|
|
|
+
|
|
|
CHECKIN_QUOTA_LIMIT = 6
|
|
|
CHECKIN_QUOTA_WINDOW = 60
|
|
|
|
|
@@ -859,7 +864,11 @@ def process_batch(executor: ThreadPoolExecutor, message: Message[ValuesBatch[Kaf
|
|
|
assert isinstance(item, BrokerValue)
|
|
|
|
|
|
try:
|
|
|
- wrapper: CheckinMessage | ClockPulseMessage = msgpack.unpackb(item.payload.value)
|
|
|
+ try:
|
|
|
+ wrapper: IngestMonitorMessage = MONITOR_CODEC.decode(item.payload.value)
|
|
|
+ except ValidationError:
|
|
|
+ wrapper = msgpack.unpackb(item.payload.value)
|
|
|
+ logger.exception("Failed to unpack message payload via sentry_kafka_schemas")
|
|
|
except Exception:
|
|
|
logger.exception("Failed to unpack message payload")
|
|
|
continue
|
|
@@ -904,7 +913,12 @@ def process_batch(executor: ThreadPoolExecutor, message: Message[ValuesBatch[Kaf
|
|
|
def process_single(message: Message[KafkaPayload]):
|
|
|
assert isinstance(message.value, BrokerValue)
|
|
|
try:
|
|
|
- wrapper = msgpack.unpackb(message.payload.value)
|
|
|
+ try:
|
|
|
+ wrapper: IngestMonitorMessage = MONITOR_CODEC.decode(message.payload.value)
|
|
|
+ except ValidationError:
|
|
|
+ logger.exception("Failed to unpack message payload via sentry_kafka_schemas")
|
|
|
+ wrapper = msgpack.unpackb(message.payload.value)
|
|
|
+
|
|
|
ts = message.value.timestamp
|
|
|
partition = message.value.partition.index
|
|
|
|