Skip to content
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: Remove default topic duplication and add kafka topic test #3361

Merged
merged 16 commits into from
Apr 10, 2024

Conversation

lynnagara
Copy link
Member

@lynnagara lynnagara commented Mar 29, 2024

Fixes related to INC-696, which accidentally had ingest-generic-metrics as the default topic name alias instead of ingest-performance-metrics.

This PR attempts to do 2 things

  • Move defining the default topic name to a single place rather than 2
  • Check the default topic names against those registered against sentry-kafka-schemas to ensure they are aligned with what the other codebases have registered as defaults

Needs getsentry/sentry-kafka-schemas#242

Note that outcomes-billing no longer defaults to outcomes and ingest-performance-metrics no longer defaults to ingest-metrics, as there is no scenario where they should share topics anymore.

Fixes related to INC-696, which accidentally had `ingest-generic-metrics`
as the default topic name alias instead of `ingest-performance-metrics`.

This PR attempts to do 2 things
- Move defining the default topic name to a single place rather than 2
- Check the default topic names against those registered against
sentry-kafka-schemas to ensure they are aligned with what the other
codebases have registered as defaults
@lynnagara lynnagara requested a review from a team as a code owner March 29, 2024 17:06
@lynnagara
Copy link
Member Author

a bit stumped by the failing integration test, any ideas how to fix it?

Comment on lines 123 to 140
define_topic_assignments! {
TopicAssignments {
events: (KafkaTopic::Events, "ingest-events"),
attachments: (KafkaTopic::Attachments, "ingest-attachments"),
transactions: (KafkaTopic::Transactions, "ingest-transactions"),
outcomes: (KafkaTopic::Outcomes, "outcomes"),
outcomes_billing: (KafkaTopic::OutcomesBilling, "outcomes-billing"),
metrics_sessions: (KafkaTopic::MetricsSessions, "ingest-metrics"),
metrics_generic: (KafkaTopic::MetricsGeneric, "ingest-performance-metrics"),
profiles: (KafkaTopic::Profiles, "profiles"),
replay_events: (KafkaTopic::ReplayEvents, "ingest-replay-events"),
replay_recordings: (KafkaTopic::ReplayRecordings, "ingest-replay-recordings"),
monitors: (KafkaTopic::Monitors, "ingest-monitors"),
spans: (KafkaTopic::Spans, "snuba-spans"),
metrics_summaries: (KafkaTopic::MetricsSummaries, "snuba-metrics-summaries"),
cogs: (KafkaTopic::Cogs, "shared-resources-usage"),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

attachments: "ingest-attachments".to_owned().into(),
transactions: "ingest-transactions".to_owned().into(),
outcomes: "outcomes".to_owned().into(),
outcomes_billing: None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we handling this special case? I assume this is the reason why integration tests are failing, see

KafkaTopic::OutcomesBilling => self.outcomes_billing.as_ref().unwrap_or(&self.outcomes),

Copy link
Member Author

@lynnagara lynnagara Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not handling it at all. This is no longer treated as a special case in any of our other services (see https://github.com/getsentry/sentry/blob/d414afaab6fcd22e8609d0a885e25cad0752b83b/src/sentry/conf/server.py#L3477 and https://github.com/getsentry/sentry-kafka-schemas/blob/main/topics/outcomes-billing.yaml for example). If someone reaalllly wanted to share the topic technically still they could accomplish it via overriding outcomes-billing back to outcomes in relay config (but that's not really something we'd do anymore). It only ever existed for dev and dev was updated to just match prod on this recently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it break self hosted?

Copy link
Member Author

@lynnagara lynnagara Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't. Self hosted runs a billing consumer too. https://github.com/getsentry/self-hosted/blob/c4ae491929170c075bea608941b227a8db81eec2/docker-compose.yml#L268-L270.

Getsentry already produces to that topic and it gets written to clickhouse similarly to before.

@jjbayer
Copy link
Member

jjbayer commented Apr 3, 2024

a bit stumped by the failing integration test, any ideas how to fix it?

I picked a few of the failing tests randomly and they all passed on my machine, must have something to with the topic configuration. I'll take another look.

Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the changes!

}

define_topic_assignments! {
TopicAssignments {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the documentation back? It should be possible to include it in the macro and just generate it on the fields using #[doc = $foo].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, added back the original descriptions

attachments: "ingest-attachments".to_owned().into(),
transactions: "ingest-transactions".to_owned().into(),
outcomes: "outcomes".to_owned().into(),
outcomes_billing: None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it break self hosted?

@Dav1dde
Copy link
Member

Dav1dde commented Apr 3, 2024

a bit stumped by the failing integration test, any ideas how to fix it?

Possibly to do with how it auto generates topic names, maybe the mapping is broken?

@jjbayer
Copy link
Member

jjbayer commented Apr 3, 2024

a bit stumped by the failing integration test, any ideas how to fix it?

I pushed an update to the test topics config, let's see if that makes tests pass 🤞

@Dav1dde
Copy link
Member

Dav1dde commented Apr 3, 2024

I pushed an update to the test topics config, let's see if that makes tests pass 🤞

I am a bit worried, this is now officially a breaking change. If we have it configured that way, somebody else will probably too (self hosted?).

Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit worried, this is now officially a breaking change. If we have it configured that way, somebody else will probably too (self hosted?).

Agreed, we should restore the existing topic aliases (see comment).

Comment on lines 130 to 131
metrics_sessions: (KafkaTopic::MetricsSessions, "ingest-metrics"),
metrics_generic: (KafkaTopic::MetricsGeneric, "ingest-performance-metrics"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to bring back the metrics and metrics_transactions aliases to ensure backward compatibility. Maybe we can tweak the macro to allow multiple aliases.

Copy link
Member Author

@lynnagara lynnagara Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need the backward compatibility for? Do we think that self-hosted users would have used these aliases? And is it the intention to support that forever? (it is not part of the default self-hosted configuration)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess to not cause a breaking change if it is unnecessary? We can also call it out as a breaking change in the changelog, the number of users who configure topics manually is probably close to zero.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the changelog in this PR. Did you want one calling it out in self-hosted too?

My personal feelings on this are that making this more complicated in order to maintain compatibility with something that probably no one has used is not really worth it. I'm not sure how this is generally handled in Relay, but in sentry and snuba codebases at least, breaking compatibility is generally fine as long as we call it out (and we did already break compatibility when this same change was shipped there)

@lynnagara lynnagara changed the title ref: Remove default topic duplication and add kafka topic test feat: Remove default topic duplication and add kafka topic test Apr 5, 2024
Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the changelog entry, it's very clear. If we are sure that this does not break default self-hosted or any other deployments maintained by us, ship it!

@lynnagara lynnagara enabled auto-merge (squash) April 9, 2024 23:29
@lynnagara lynnagara disabled auto-merge April 9, 2024 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants