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

Preparing for producer diagnostics #1452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

erikvanoosten
Copy link
Collaborator

@erikvanoosten erikvanoosten commented Feb 5, 2025

It has been a long wish to have producer diagnostics. Although these are not really hard to add, the consumer diagnostics are a bit in the way; these already claim some names and make code sharing awkward. Now that we are moving towards zio-kafka 3.0 we can fix these at the cost of some backward incompatibilities.

This PR prepares for the introduction of producer diagnostics by moving the consumer diagnostics specific code out of the diagnostics package, while keeping the sharable code there.

The following changes are proposed (fixable with scalafix):

Old New
zio.kafka.consumer.diagnostics.Diagnostics zio.kafka.consumer.Consumer.ConsumerDiagnostics
zio.kafka.consumer.diagnostics.Diagnostics.NoOp zio.kafka.consumer.Consumer.NoDiagnostics
zio.kafka.consumer.diagnostics.DiagnosticEvent zio.kafka.consumer.ConsumerDiagnosticEvent
zio.kafka.consumer.diagnostics.DiagnosticEvent.* zio.kafka.consumer.ConsumerDiagnosticEvent.*
zio.kafka.consumer.diagnostics.DiagnosticEvent.Finalization.* zio.kafka.consumer.ConsumerDiagnosticEvent.*

Different invocation:
old: zio.kafka.consumer.diagnostics.Diagnostics.SligingQueue.make()
new: zio.kafka.diagnostics.SlidingDiagnostics.make[ConsumerDiagnosticEvent]()

Move to internal or test package:

Old New New location
zio.kafka.consumer.diagnostics.Diagnostics.ConcurrentDiagnostics zio.kafka.diagnostics.internal.ConcurrentDiagnostics internal
zio.kafka.consumer.diagnostics.DiagnosticEvent.Finalization removed -

Notes:

  • The intermediate trait DiagnosticEvent.Finalization was removed from the type hierarchy because it doesn't serve any user purpose (it was introduced to make it easier to test the shutdown sequence of the consumer).

@erikvanoosten erikvanoosten added this to the 3.0.0 milestone Feb 5, 2025
@erikvanoosten erikvanoosten force-pushed the producer-diagnostics branch 2 times, most recently from 85249b2 to 36bfae6 Compare February 8, 2025 11:52
@erikvanoosten
Copy link
Collaborator Author

Hint for the reviewer: enable 'hide whitespace' to minimize the diff.

It has been a long wish to have producer diagnostics. Although these are not really hard to add, the consumer diagnostics are a bit in the way; these already claim some names and make code sharing awkward. Now that we are moving towards zio-kafka 3.0 we can fix these at the cost of some backward incompatibilities.

This PR prepares for the introduction of producer diagnostics by moving the consumer diagnostics specific code out of the diagnostics package, while keeping the sharable code there.

The following changes are proposed (fixable with scalafix):

| Old | New |
| --- | --- |
| `zio.kafka.consumer.diagnostics.Diagnostics` | `zio.kafka.consumer.Consumer.ConsumerDiagnostics` |
| `zio.kafka.consumer.diagnostics.Diagnostics.NoOp` | `zio.kafka.consumer.Consumer.NoDiagnostics` |
| `zio.kafka.consumer.diagnostics.DiagnosticEvent` | `zio.kafka.consumer.ConsumerDiagnosticEvent` |
| `zio.kafka.consumer.diagnostics.DiagnosticEvent.*` | `zio.kafka.consumer.ConsumerDiagnosticEvent.*` |
| `zio.kafka.consumer.diagnostics.DiagnosticEvent.Finalization.*` | `zio.kafka.consumer.ConsumerDiagnosticEvent.*` |

Different invocation:
old: `zio.kafka.consumer.diagnostics.Diagnostics.SligingQueue.make()`
new: `zio.kafka.diagnostics.SlidingDiagnostics.make[ConsumerDiagnosticEvent]()`

Move to internal or test package:

| Old | New | New location |
| --- | --- | --- |
| `zio.kafka.consumer.diagnostics.Diagnostics.ConcurrentDiagnostics` | `zio.kafka.diagnostics.internal.ConcurrentDiagnostics` | internal |
| `zio.kafka.consumer.diagnostics.DiagnosticEvent.Finalization` | removed | - |

Notes:

- The intermediate trait `DiagnosticEvent.Finalization` was removed from the type hierarchy because it doesn't serve any user purpose (it was introduced to make it easier to test the shutdown sequence of the consumer).
@erikvanoosten erikvanoosten marked this pull request as draft February 13, 2025 16:19
@erikvanoosten erikvanoosten marked this pull request as ready for review February 19, 2025 16:42
Copy link
Contributor

@vermas7988 vermas7988 left a comment

Choose a reason for hiding this comment

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

I did a review. Just two suggestions if they are applicable.

@svroonland
Copy link
Collaborator

I can see the use in generalizing SlidingDiagnostics and ConcurrentDiagnostics by parameterizing them with the type of diagnostic event. But I'd like to see if we can keep the rest of the stuff in the same package and with the same name, just to minimize changes.

What would be the downside of having zio.kafka.consumer.diagnostics.DiagnosticEvent and zio.kafka.producer.diagnostics.DiagnosticEvent for example?

@erikvanoosten
Copy link
Collaborator Author

What would be the downside of having zio.kafka.consumer.diagnostics.DiagnosticEvent and zio.kafka.producer.diagnostics.DiagnosticEvent for example?

One downside is that its very annoying when you have a scala file that needs both classes.
But your proposal is not unreasonable. I'll try it out.

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