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

[close #397] add git commit hash and version info while TiSession create #408

Merged
merged 5 commits into from
Dec 22, 2021

Conversation

iosmanthus
Copy link
Member

Signed-off-by: iosmanthus myosmanthustree@gmail.com

What problem does this PR solve?

Add info logs while Tisession create

Issue Number: close #397

Problem Description: TBD

What is changed and how it works?

Check List for Tests

This PR has been tested by at least one of the following methods:

  • Manual test (add detailed scripts or steps below)

Related changes

  • Need to cherry-pick to the release branch

logger.info("Release Version: " + properties.getProperty("git.build.version"));
logger.info("Git Commit Hash: " + properties.getProperty("git.commit.id.full"));
} catch (Exception e) {
logger.error("Fail to read package info: " + e.getMessage());
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 it's better to set it to info level since users don't need to perform any operation after seeing this log.

Comment on lines 113 to 114
logger.info("Release Version: " + properties.getProperty("git.build.version"));
logger.info("Git Commit Hash: " + properties.getProperty("git.commit.id.full"));
Copy link
Member

Choose a reason for hiding this comment

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

it's better to aggregate them into one log item to:

  1. reduce the log items and the total log size.
  2. reduce the log search (i.e. grep) burden

printVersionInfo();
}

private void printVersionInfo() {
Copy link
Member

Choose a reason for hiding this comment

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

how about refactoring this function to:

private void getVersionInfo() String {
}

then log the info in TiSession and add a UT for this function.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's hard to write suck UT to assert the commit hash.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now, I capture these logic into VersionInfo, PTAL.

pom.xml Show resolved Hide resolved
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
String commitHash = properties.getProperty("git.commit.id.full");
info = new VersionInfo(version, commitHash);
} catch (Exception e) {
logger.info("Fail to read package info: " + e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
logger.info("Fail to read package info: " + e.getMessage());
logger.error("Fail to read package info: " + e.getMessage());

Copy link
Member Author

Choose a reason for hiding this comment

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

conflicted with: #408 (comment). Personally speaking, I think the error log level could help us discover some building issues.

@@ -103,6 +120,22 @@ public TiSession(TiConfiguration conf) {
warmUp();
this.circuitBreaker = new CircuitBreakerImpl(conf);
logger.info("TiSession initialized in " + conf.getKvMode() + " mode");
logger.info("Welcome to TiKV Java Client {}", getVersionInfo());
Copy link
Member

Choose a reason for hiding this comment

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

It would print a welcome message when every new TiSession is created. Considering that an application can use multiple TiSessions, is there a better place to print this message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@marsishandsome marsishandsome left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason
Copy link
Member

/merge

@ti-srebot
Copy link
Collaborator

/run-all-tests

@zz-jason zz-jason changed the title [close #397 ] add git commit hash and version info while TiSession create [close #397] add git commit hash and version info while TiSession create Dec 22, 2021
@zz-jason zz-jason merged commit f5b8d97 into tikv:master Dec 22, 2021
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.

print version number, commit hash, and config items after java client initialized
5 participants