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

HIVE-26670: Track every single HTTP request between beeline and hs2 #3710

Merged
merged 2 commits into from Nov 1, 2022

Conversation

abstractdog
Copy link
Contributor

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

Copy link
Contributor

@cnauroth cnauroth left a comment

Choose a reason for hiding this comment

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

Thanks, @abstractdog ! This looks useful. I entered a few comments. Additionally, have you explored if any unit testing is possible?

@abstractdog
Copy link
Contributor Author

Thanks, @abstractdog ! This looks useful. I entered a few comments. Additionally, have you explored if any unit testing is possible?

thanks a lot @cnauroth! honestly, I haven't found existing unit tests in this area to extend easily, and I was lazy :) but it's time now to improve, let me check

@abstractdog
Copy link
Contributor Author

@cnauroth, pushed a new commit: 7579d5f
can you check if it's okay?

Copy link
Contributor

@cnauroth cnauroth left a comment

Choose a reason for hiding this comment

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

@abstractdog , thanks for incorporating the code review feedback! I have just a few more questions.

Copy link
Contributor

@cnauroth cnauroth left a comment

Choose a reason for hiding this comment

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

+1 (non-binding)

@abstractdog , thanks for your patience responding to the code review feedback!

@abstractdog
Copy link
Contributor Author

abstractdog commented Oct 29, 2022

+1 (non-binding)

@abstractdog , thanks for your patience responding to the code review feedback!

thanks a lot @cnauroth for the quality code review!

Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

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

Thanx Laszlo, just some nits.
rest LGTM

if (trackHeader == null) {
return;
}
long elapsed = System.currentTimeMillis() - (long) context.getAttribute(trackHeader + "_TIME");
Copy link
Member

Choose a reason for hiding this comment

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

nit:
Can use Constants.TIME_POSTFIX_REQUEST_TRACK instead of hardcoding _TIME here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, night catch! that's why I created this constant
fixing it

@@ -813,6 +817,27 @@ RegistryBuilder.<ConnectionSocketFactory> create().register("https", socketFacto
return httpClientBuilder.build();
}

private boolean isRequestTrackingEnabled() {
return Boolean.valueOf(sessConfMap.get(JdbcConnectionParams.JDBC_PARAM_REQUEST_TRACK));
Copy link
Member

Choose a reason for hiding this comment

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

Can replace with:

    return Boolean.parseBoolean(sessConfMap.get(JdbcConnectionParams.JDBC_PARAM_REQUEST_TRACK));

Boolean.valueOf does a parseBoolean which returns a primitive boolean, which is converted into Boolean and now you are again returning a primitive boolean, the conversion from boolean to Boolean is unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack, thanks!

LOG.info("{}:{}", Constants.HTTP_HEADER_REQUEST_TRACK, trackHeader);
additionalHeaders.put(Constants.HTTP_HEADER_REQUEST_TRACK, trackHeader);
httpContext.setAttribute(Constants.HTTP_HEADER_REQUEST_TRACK, trackHeader);
httpContext.setAttribute(trackHeader + Constants.TIME_POSTFIX_REQUEST_TRACK, System.currentTimeMillis());
Copy link
Member

Choose a reason for hiding this comment

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

We are using System.currentTimeMillis() to calculate the duration. I am not very sure, if using Time.monotonicNow() Will be better.
Just by the doc:
https://github.com/apache/hadoop/blob/b1f418f8027c2d2a1a1c17ec3a8d23ceaaf8d89c/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Time.java#L49-L69

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I tend to use System.currentTimeMillis(), hadoop util looks better clearly according to javadoc

@abstractdog
Copy link
Contributor Author

Thanx Laszlo, just some nits. rest LGTM

thanks, fixed them!

@sonarcloud
Copy link

sonarcloud bot commented Nov 1, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@abstractdog abstractdog merged commit 1afd305 into apache:master Nov 1, 2022
dengzhhu653 pushed a commit to dengzhhu653/hive that referenced this pull request Dec 15, 2022
DongWei-4 pushed a commit to DongWei-4/hive that referenced this pull request Dec 29, 2022
…pache#3710) (Laszlo Bodor reviewed by Ayush Saxena, Chris Nauroth)

(cherry picked from commit 1afd305)
yeahyung pushed a commit to yeahyung/hive that referenced this pull request Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants