Skip to content

[PECOBLR-335] Unify logging + telemetry across the repo#812

Merged
samikshya-db merged 7 commits into
mainfrom
samikshya-chand_data/unifyLoggingMessages
Apr 30, 2025
Merged

[PECOBLR-335] Unify logging + telemetry across the repo#812
samikshya-db merged 7 commits into
mainfrom
samikshya-chand_data/unifyLoggingMessages

Conversation

@samikshya-db
Copy link
Copy Markdown
Collaborator

@samikshya-db samikshya-db commented Apr 25, 2025

Description

  • Unify logging across. This will help pass accurate debug logs.
  • Avoiding the use of Log(String.format(""...%s", stringText) -> this is because SLF4J inbuilt interpolation of string lazily does the job (i.e., interpolates only if specified log level is on + log is passed) -> hence is more performant.
  • There were some exceptions that needed to be changed to internal exception implementation. Addressed that in this PR

Testing

  • Updated the LoggingTests
  • Ran E2E Examples locally

Additional Notes to the Reviewer

NO_CHANGELOG=true

@samikshya-db samikshya-db changed the title Unify logging across the repo [PECOBLR-335] Unify logging across the repo Apr 25, 2025
String errorMessage =
String.format("Error converting element at index %s: %s", i, e.getMessage());
LOGGER.error(errorMessage, e);
LOGGER.error(e, errorMessage);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At multiple places, like this, the string.format is not inline, what should we do about this to take advantage of lazy eval?

Copy link
Copy Markdown
Collaborator Author

@samikshya-db samikshya-db Apr 25, 2025

Choose a reason for hiding this comment

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

At multiple places

No, only in case of errors. This is because we anyway need the string for throwing an exception.

@Override
public void setLoginTimeout(int seconds) {
LOGGER.debug(String.format("public void setLoginTimeout(int seconds = {%s})", seconds));
LOGGER.debug("public void setLoginTimeout(int seconds = {})", seconds);
Copy link
Copy Markdown
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 this will work, JDBC uses JUL by default and that does not recognise {} so it will just add {} to the log

Copy link
Copy Markdown
Collaborator Author

@samikshya-db samikshya-db Apr 25, 2025

Choose a reason for hiding this comment

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

I don't think this will work,

How so?

I have tested this locally as well as the logging integration test works. I have also changed the JUL implementation in this PR, can you take a look?

Copy link
Copy Markdown
Collaborator

@vikrantpuppala vikrantpuppala Apr 25, 2025

Choose a reason for hiding this comment

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

have also changed the JUL implementation in this PR

oh sorry missed this, will re-review

return DEFAULT_PACKAGE_PREFIX;
}

private String slf4jToJavaFormat(String format) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

Comment thread src/main/java/com/databricks/jdbc/common/util/DriverUtil.java Outdated
Comment thread src/main/java/com/databricks/jdbc/common/util/DriverUtil.java Outdated
String stackTraceMessage =
format(
"DatabricksResultSet executeInternal(String sql = %s,Map<Integer, ImmutableSqlParameter> params = {%s}, StatementType statementType = {%s})",
"DatabricksResultSet executeInternal(String sql = %s, Map<Integer, ImmutableSqlParameter> params = {%s}, StatementType statementType = {%s})",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need {%s} here?

Copy link
Copy Markdown
Collaborator Author

@samikshya-db samikshya-db Apr 25, 2025

Choose a reason for hiding this comment

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

%s is required as we are using the String.format method (because it is an exception error message)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yeah, i guess my question was do we need the braces since we changed {%s} to {} at certain places in this PR.. so do we want to change {%s} to just %s here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Either works, as long as we have the string required.

Comment thread src/main/java/com/databricks/jdbc/telemetry/TelemetryPushTask.java Outdated
Comment thread src/main/java/com/databricks/jdbc/telemetry/TelemetryClientFactory.java Outdated
@samikshya-db samikshya-db changed the title [PECOBLR-335] Unify logging across the repo [PECOBLR-335] Unify logging + telemetry across the repo Apr 25, 2025
@samikshya-db samikshya-db merged commit 1150b93 into databricks:main Apr 30, 2025
10 of 16 checks passed
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.

3 participants