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

Operation (Query) Metrics #1633

Merged
merged 10 commits into from
May 22, 2024
Merged

Operation (Query) Metrics #1633

merged 10 commits into from
May 22, 2024

Conversation

chernser
Copy link
Contributor

@chernser chernser commented May 14, 2024

Summary

Adds class to represent metrics of an operation.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@chernser chernser linked an issue May 14, 2024 that may be closed by this pull request
3 tasks
@chernser chernser marked this pull request as ready for review May 21, 2024 07:34
}

public void start() {
startNanoTime = System.nanoTime();
Copy link
Contributor

Choose a reason for hiding this comment

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

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've found some good doc from JDK developer https://web.archive.org/web/20160308031939/https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks
It explains why nanoTime() may be slow and what should be used for precise measurement.

Conclusion:

  • nanoTime() may be slow in scale of microseconds
  • nanoTime() may require hardware IO and that is why it may be slow
  • nanoTime() is what recommended for elapsed time measurements.
  • currentTimeMillis() is not so precise and may have a lag of 10ms
  • we will use nanoTime() until we see a noticeable drop in performance.

private static final String INTERNAL_OPERATION_ID = "operationID";

private String startOperation() {
String operationId = UUID.randomUUID().toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sending operationId also as query_id this can be a good connection between our code and the actual operation in ClickHouse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

@chernser chernser merged commit bfc4c60 into main May 22, 2024
56 of 58 checks passed
@chernser chernser deleted the feat-metrics branch May 24, 2024 17:54
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.

[client-v2] Query API Response Metrics
3 participants