Skip to content

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

CLAassistant commented May 14, 2024

CLA assistant check
All committers have signed the CLA.

@chernser chernser linked an issue May 14, 2024 that may be closed by this pull request
3 tasks
@chernser chernser requested review from Paultagoras and mzitnik May 21, 2024 07:34
@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
@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

5 participants