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

SNOW-1271301 add telemetry fields and use the metrics ExecTimeTelemet… #1762

Closed

Conversation

sfc-gh-dbouassida
Copy link
Contributor

@sfc-gh-dbouassida sfc-gh-dbouassida commented May 21, 2024

Overview

This PR is still WIP. Feedback is needed for the general logic of the enhanced telemetry.
Tests are to be added.

Pre-review self checklist

  • PR branch is updated with all the changes from master branch
  • The code is correctly formatted (run mvn -P check-style validate)
  • New public API is not unnecessary exposed (run mvn verify and inspect target/japicmp/japicmp.html)
  • The pull request name is prefixed with SNOW-XXXX:

External contributors - please answer these questions before submitting a pull request. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency or upgrading an existing one
    • I am adding new public/protected component not marked with @SnowflakeJdbcInternalApi (note that public/protected methods/fields in classes marked with this annotation are already internal)
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

Copy link


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 can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@sfc-gh-dbouassida sfc-gh-dbouassida force-pushed the SNOW-1271301-jdbc-enhanced-telemetry branch from d317a7f to f58477c Compare May 21, 2024 09:29
@sfc-gh-dbouassida
Copy link
Contributor Author

sfc-gh-dbouassida commented May 21, 2024

This PR is still WIP. Feedback is needed for the general logic of the enhanced telemetry.
Tests are to be added.

@sfc-gh-dbouassida sfc-gh-dbouassida force-pushed the SNOW-1271301-jdbc-enhanced-telemetry branch 2 times, most recently from d405797 to ffea8b2 Compare May 21, 2024 09:43
Copy link
Collaborator

@sfc-gh-dprzybysz sfc-gh-dprzybysz left a comment

Choose a reason for hiding this comment

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

I left some comments - please also think about tests for your changes

private String requestId;

public ExecTimeTelemetryData(String queryFunction, String batchId) {
if (TelemetryService.getInstance().isHTAPEnabled()) {
if (TelemetryService.getInstance().isHTAPEnabled()
|| TelemetryService.getInstance().isClientTelemetryEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's create a single method in TelemetryService to decide if the telemetry is turned on here

@@ -24,4 +24,9 @@ public static Optional<QueryResultFormat> lookupByName(String n) {

return Optional.empty();
}

@Override
public String toString() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it should be toString but more getName() or better getParameterValue()

@@ -160,6 +160,9 @@ public SFArrowResultSet(
// update the driver/session with common parameters from GS
SessionUtil.updateSfDriverParamValues(this.parameters, statement.getSFBaseSession());

// send a metric to tell the result format is arrow
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't think we should keep such comments - the method name is quite expressive

* @param value the value to log for the field
* @return TelemetryData instance constructed from parameters
*/
public static TelemetryData buildJobData(String queryId, TelemetryField field, String value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we create a method where the value is Object and make the method above using the new one and make the old method deprecated?

@@ -179,6 +190,26 @@ public void addRetryLocation(String location) {

public String generateTelemetry() {
if (this.sendData) {
if (this.telemetryClient != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it means that we are using this method to generate one event and by the way create 3 other events? I don't think it should happen in one method

also do we want to generate separate events to the batch? cannot we add them to the ExecutionTimeRecord created below?

@@ -142,6 +164,10 @@ public boolean isHTAPEnabled() {
}
}

public boolean isTelemetryEnabled() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should it be isInBoundTelemetryEnabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this method is called by the ExecTimeTelemetryData. it is true when isHTAPEnabled or isClientTelemetryEnabled. It can haooen that isClientTelemetryEnabled is false and thus InBoundTelemetry is false, but isHTAPEnabled is true.
The ExecTimeTelemetryData will collect data when either of oob or ib telemetries is enabled.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But it does not seems to be right that on the session parameter we are changing the global state - but it's already merged for a long time

Nevertheless. For sending the new telemetry events you are adding we should be do this via inbound telemetry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it should go to to client_telemetry_v with the session and query_id. There are already some fields that are sent, we are trying to add more.

}
}

public boolean isClientTelemetryEnabled() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could this method be private?

@@ -656,6 +656,11 @@ public synchronized void open() throws SFException, SnowflakeSQLException {
} else {
TelemetryService.disableHTAP();
}
if (isClientTelemetryEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

inbound telemetry is enabled per session - but here we set it on the static level - do we need it at all? can we just use the flag from the session wherever it's necessary?

SNOW-1271301 entcouple the TelemetryClinet and the TelemetryService

SNOW-1271301 entcouple the ExecTimeTelemetryData and the TelemetryClinet

SNOW-1271301 add client_time_response_from_server

SNOW-1271301 add telemetry fields and use the metrics ExecTimeTelemetryData to send telemetry.
@sfc-gh-dbouassida sfc-gh-dbouassida force-pushed the SNOW-1271301-jdbc-enhanced-telemetry branch from 2453b50 to 9eafabf Compare June 24, 2024 09:02
@sfc-gh-pbulawa sfc-gh-pbulawa removed their request for review August 27, 2024 13:31
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants