-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(spans): Add a new recombiner consumer #66804
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8967184
feat(spans): Add a new recombiner consumer
shruthilayaj c572d4d
feat(spans): Add a new recombiner consumer
shruthilayaj fa28176
fix tests
shruthilayaj 475de51
test recombiner consumer
shruthilayaj 4a3e304
remove refs to celery queues
shruthilayaj c086d65
clean up
shruthilayaj f223c1b
remove from celery imports
shruthilayaj 54058c8
mege conflicts
shruthilayaj 7608e4e
plularize topic name
shruthilayaj 9a0adc7
use BUFFERED_SEGMENT_SCHEMA, update tests
shruthilayaj b9b6bfc
remove unnecessary test
shruthilayaj 6a14c4d
update expected type for process_segment
shruthilayaj beeb90c
remove leading slashes
shruthilayaj 4c9d463
Merge branch 'master' into shruthi/feat/add-recombiner-consumer
shruthilayaj cf67f96
typing
shruthilayaj dabf343
rename consumer
shruthilayaj 821c8d6
merge conflicts
shruthilayaj 0918a0b
merge conflicts
shruthilayaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
from collections.abc import Mapping | ||
from typing import Any | ||
|
||
from arroyo.backends.kafka.consumer import KafkaPayload | ||
from arroyo.processing.strategies.abstract import ProcessingStrategy, ProcessingStrategyFactory | ||
from arroyo.processing.strategies.commit import CommitOffsets | ||
from arroyo.processing.strategies.run_task import RunTask | ||
from arroyo.types import BrokerValue, Commit, Message, Partition | ||
from sentry_kafka_schemas import get_codec | ||
from sentry_kafka_schemas.codecs import Codec, ValidationError | ||
from sentry_kafka_schemas.schema_types.buffered_segments_v1 import BufferedSegment | ||
|
||
from sentry.spans.consumers.recombine.message import process_segment | ||
|
||
BUFFERED_SEGMENT_SCHEMA: Codec[BufferedSegment] = get_codec("buffered-segments") | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def _deserialize_segment(value: bytes) -> Mapping[str, Any]: | ||
return BUFFERED_SEGMENT_SCHEMA.decode(value) | ||
|
||
|
||
def process_message(message: Message[KafkaPayload]): | ||
try: | ||
segment = _deserialize_segment(message.payload.value) | ||
except ValidationError: | ||
logger.exception("Failed to deserialize segment payload") | ||
return | ||
|
||
process_segment(segment["spans"]) | ||
|
||
|
||
def _process_message(message: Message[KafkaPayload]): | ||
assert isinstance(message.value, BrokerValue) | ||
|
||
try: | ||
process_message(message) | ||
except Exception: | ||
logger.exception("Failed to process segment payload") | ||
|
||
|
||
class RecombineSegmentStrategyFactory(ProcessingStrategyFactory[KafkaPayload]): | ||
def create_with_partitions( | ||
self, | ||
commit: Commit, | ||
partitions: Mapping[Partition, int], | ||
) -> ProcessingStrategy[KafkaPayload]: | ||
return RunTask( | ||
function=_process_message, | ||
next_step=CommitOffsets(commit), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do those have a
/
prefixed in contrast to the others?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch!