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

Dead code in metrics exporter #9760

Closed
falko opened this issue Jul 12, 2022 · 3 comments · Fixed by #18469
Closed

Dead code in metrics exporter #9760

falko opened this issue Jul 12, 2022 · 3 comments · Fixed by #18469
Assignees
Labels
area/maintainability Marks an issue as improving the maintainability of the project area/observability Marks an issue as observability related component/exporter component/zeebe Related to the Zeebe component/team kind/toil Categorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc.

Comments

@falko
Copy link
Member

falko commented Jul 12, 2022

After @korthout added a RecordFilter in db64a95 the following code block should be dead code because no other record types would arrive in the exporter
https://github.com/camunda/zeebe/blob/2c52c6a764ed6d9bcc19428d9a2592a3888ed741/broker/src/main/java/io/camunda/zeebe/broker/exporter/metrics/MetricsExporter.java#L92

@korthout korthout added kind/toil Categorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc. area/maintainability Marks an issue as improving the maintainability of the project labels Jul 12, 2022
@Zelldon Zelldon added component/exporter area/observability Marks an issue as observability related labels Jan 2, 2023
@romansmirnov romansmirnov added the component/zeebe Related to the Zeebe component/team label Mar 5, 2024
@npepinpe
Copy link
Member

I think we can close this now.

@falko
Copy link
Member Author

falko commented May 13, 2024

The same code is still there:
https://github.com/camunda/zeebe/blob/90911096a1e21b1ece3c181ea4c42151faafcf73/zeebe/broker/src/main/java/io/camunda/zeebe/broker/exporter/metrics/MetricsExporter.java#L109-L112

and can still not be reached due to:
https://github.com/camunda/zeebe/blob/90911096a1e21b1ece3c181ea4c42151faafcf73/zeebe/broker/src/main/java/io/camunda/zeebe/broker/exporter/metrics/MetricsExporter.java#L82-L85

It looks to me like a cleanup or potential performance optimization to immediately advance the exporter position after ignoring a record and allowing for log compaction. On the other hand, such a behavior should be part of the generic RecordFilter mechanism anyway and thus make this code unnecessary in exporter implementations.

I am also asking to generally understand best practices for writing exporters. Should all exporters have this cleanup even if they use record filters? Or is it enough to rely on events occurring sufficiently frequent even in case the ExporterDirector does not advance the position:
https://github.com/camunda/zeebe/blob/90911096a1e21b1ece3c181ea4c42151faafcf73/zeebe/broker/src/main/java/io/camunda/zeebe/broker/exporter/stream/ExporterContainer.java#L184-L188

@npepinpe
Copy link
Member

npepinpe commented May 13, 2024

No, this is likely an artifact from before we had record filters 👍 I'll remove it. That said, I would expect the JVM to eventually optimize this code and make this almost a noop.

As best practice, always use record filter, as it may allow us to skip a record entirely without reading it.

@npepinpe npepinpe self-assigned this May 13, 2024
@npepinpe npepinpe reopened this May 13, 2024
github-merge-queue bot pushed a commit that referenced this issue May 14, 2024
## Description

Removes an unnecessary condition to exit early if the record is not
event. This is unnecessary because we're already applying a record
filter for the exporter which only accepts events.

## Related issues

closes #9760
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maintainability Marks an issue as improving the maintainability of the project area/observability Marks an issue as observability related component/exporter component/zeebe Related to the Zeebe component/team kind/toil Categorizes an issue or PR as general maintenance, i.e. cleanup, refactoring, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants