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

BP-58: Change the API for org.apache.bookkeeper.stats.Counter #3501

Merged
merged 5 commits into from Sep 27, 2022

Conversation

StevenLuMT
Copy link
Contributor

@StevenLuMT StevenLuMT commented Sep 23, 2022

Descriptions of the changes in this PR:

Motivation

The latency of the OpStatsLogger.registerSuccessfulEvent calculation is to convert the time to milliseconds
image
but Counter.add nothing to do

so when using Counter for latency statistics, the time unit and OpStatsLogger are not unified, which is easy to be misleading.
then we unified latency metric unit

Changes

  1. change name : Counter.add --> Counter.addCount
  2. add new method Counter.addLatency to count the time and convert the time to milliseconds

then how to use counter correctly:

  1. when using Counter for latency metric, call Counter.addLatency
  2. when using Counter for count metric, call Counter.addCount

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Lgtm

But we can't cherry pick this into released branches

@shoothzj
Copy link
Member

will this break prometheus metric result?

@StevenLuMT
Copy link
Contributor Author

will this break prometheus metric result?

this change don't break prometheus metric result:
This just optimize the statistics,but in the end this logic still use Counter.add to update the data
@shoothzj
image

Copy link
Member

@wenbingshen wenbingshen left a comment

Choose a reason for hiding this comment

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

nice found.

updateMax(val.addAndGet(delta));
}

@Override
public void addLatency(long eventLatency, TimeUnit unit) {
long valueMillis = unit.toMicros(eventLatency) / 1000;
Copy link
Member

Choose a reason for hiding this comment

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

Just have a question. Why not use unit.toMills?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just have a question. Why not use unit.toMills?

it's the same, just use the logic with OpStatsLogger.registerSuccessfulEvent @zymap
image

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 can both use unit.toMills

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can both use unit.toMills

goog idea, I will update it @shoothzj @zymap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shoothzj have a look the new update for unit.toMillis

@zymap zymap added this to the 4.16.0 milestone Sep 27, 2022
@StevenLuMT
Copy link
Contributor Author

@shoothzj have a look the new update for unit.toMillis

@shoothzj shoothzj merged commit 1e387f8 into apache:master Sep 27, 2022
@eolivelli
Copy link
Contributor

@shoothzj this is a PR related to a BP and we did not run the VOTE.
I will send a message on dev@

We should follow the community process

@eolivelli eolivelli changed the title unified latency metric unit BP-58: Change the API for org.apache.bookkeeper.stats.Counter Sep 27, 2022
@shoothzj
Copy link
Member

@eolivelli Sorry, My fault, I didn't realize it. Should we revert the PR now or wait for the vote result?

@StevenLuMT
Copy link
Contributor Author

@eolivelli Sorry, My fault, I didn't realize it. Should we revert the PR now or wait for the vote result?

@shoothzj don't revert ,see the detail for mail discussion:
image

https://lists.apache.org/thread/zyj3z3tt4bsx928mc0ogfkv63w9t47bc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants