Skip to content

Commit

Permalink
feat: Occasionally log errors if no schema found (#4392)
Browse files Browse the repository at this point in the history
We use the validation errors in prod (especially the attached message.txt) to
iterate on the schema. This is kind of a hack to get hold of example
messages before a schema is defined to help speed up the process of creating
a schema for topics where we don't have them yet.
  • Loading branch information
lynnagara authored Jun 21, 2023
1 parent 530118b commit 2bb6fc5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion snuba/consumers/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

from snuba import environment, state
from snuba.clickhouse.http import JSONRow, JSONRowEncoder, ValuesRowEncoder
from snuba.consumers.schemas import get_json_codec
from snuba.consumers.schemas import _NOOP_CODEC, get_json_codec
from snuba.consumers.types import KafkaMessageMetadata
from snuba.datasets.storage import WritableTableStorage
from snuba.datasets.storages.factory import get_writable_storage
Expand Down Expand Up @@ -553,6 +553,10 @@ def process_message(
scope.set_tag("snuba_logical_topic", snuba_logical_topic.name)

try:
# Occasionally log errors if no validator is configured
if codec == _NOOP_CODEC:
raise Exception("No validator configured for topic")

codec.validate(decoded)
except Exception as err:
local_metrics.increment(
Expand Down

0 comments on commit 2bb6fc5

Please sign in to comment.