-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat(log): added log statements to gend autocfg #1053
feat(log): added log statements to gend autocfg #1053
Conversation
e1e4b56
to
fa7963e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general. Got a couple of minor comments below.
Other than that, you might want to rebase to take in #1054 I merged in earlier. Sorry about the timing.
src/test/java/com/google/api/generator/spring/SpringAutoConfigClassComposerTest.java
Outdated
Show resolved
Hide resolved
+ " }\n" | ||
+ " if (this.clientProperties.getExecutorThreadCount() != null) {\n" | ||
+ " ExecutorProvider executorProvider =\n" | ||
+ " EchoSettings.defaultExecutorProviderBuilder()\n" | ||
+ " .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount())\n" | ||
+ " .build();\n" | ||
+ " clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider);\n" | ||
+ " LOGGER.info(\"Background executor set to \" + executorProvider.getClass().getName());\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably more useful to expose this.clientProperties.getExecutorThreadCount()
instead in the log here.
+ " }\n" | ||
+ " if (this.clientProperties.getExecutorThreadCount() != null) {\n" | ||
+ " ExecutorProvider executorProvider =\n" | ||
+ " EchoSettings.defaultExecutorProviderBuilder()\n" | ||
+ " .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount())\n" | ||
+ " .build();\n" | ||
+ " clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider);\n" | ||
+ " LOGGER.info(\"Background executor set to \" + executorProvider.getClass().getName());\n" | ||
+ " }\n" | ||
+ " if (this.clientProperties.getUseRest()) {\n" | ||
+ " clientSettingsBuilder.setTransportChannelProvider(\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only had the quota-project-id and thread-count in mind for the loggings initially, which you already implemented.
But it might be beneficial to also add logger statement inside each of the if
statements? So user can have more dubug info about properties that are set on top of defaults. What do you think?
@@ -136,6 +144,56 @@ public static List<? extends AstNode> processRetrySettings( | |||
return resultList; | |||
} | |||
|
|||
public static Statement getLoggerDeclarationExpr(String className, Map<String, TypeNode> types) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, Perhaps add it to a separate LoggerUtils.java
and put both under a utils
folder? I feel everything in this one class starts to feel cluttered. I'll separate out unrelated methods in current Utils.java
later in a separate pr.
src/main/java/com/google/api/generator/spring/composer/SpringAutoConfigClassComposer.java
Outdated
Show resolved
Hide resolved
3579b7c
to
854f34a
Compare
8832d0c
to
28269bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (and apologies again for the conflicts introduced from earlier PRs!)
Added log statements and setup in autoconfig class. Some common methods were put in Util in case they have to be reused
- added rest of logger statements (1 per if-statement) - used getExecutorThreadCount() to log number of threads - moved logging utils to its own class
0a0c92b
to
5041b71
Compare
Kudos, SonarCloud Quality Gate passed! |
* feat(log): added log statements to gend autocfg Added log statements and setup in autoconfig class. Some common methods were put in Util in case they have to be reused * fix(log): fixes from PR comments - added rest of logger statements (1 per if-statement) - used getExecutorThreadCount() to log number of threads - moved logging utils to its own class * fix(format): ran google_java_format * fix(test): updated goldens * fix: add license header to LoggerUtil
…tatic types instead of vapor references (#1046) Adding Spring related dependencies to build files and use static types instead of vapor references. Benefit of this change: - easier to test - less code change needed for future changes (e.g. package change of classes). One caveat is that because `gapic-generator-java` is brought into `googleapis` as `http_archive` code addition to `googleapis` is also needed to include these libraries. Add below code snippet to [WORKSPACE](https://github.com/googleapis/googleapis/blob/38e8b447d173909d3b2fe8fdc3e6cbb3c85442fd/WORKSPACE#L239-L245): ``` SPRING_MAVEN_ARTIFACTS = [ "org.springframework.boot:spring-boot-starter:2.7.4", "com.google.cloud:spring-cloud-gcp-core:3.3.0", ] maven_install( artifacts = PROTOBUF_MAVEN_ARTIFACTS + SPRING_MAVEN_ARTIFACTS, generate_compat_repositories = True, repositories = [ "https://repo.maven.apache.org/maven2/", ], ) ``` ------------ Updates: - Updated pr with #1065, - Moved annotation classed added in #1045 to static types. - Fixed conflicts from merged changes in #1093 - Moved logging classes added in #1053 to static types.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api:api-common](https://togithub.com/googleapis/api-common-java) | `2.2.2` -> `2.3.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api:api-common/2.3.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api:api-common/2.3.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api:api-common/2.3.1/compatibility-slim/2.2.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api:api-common/2.3.1/confidence-slim/2.2.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>googleapis/api-common-java</summary> ### [`v2.3.1`](https://togithub.com/googleapis/api-common-java/blob/HEAD/CHANGELOG.md#​231-httpsgithubcomgoogleapisapi-common-javacomparev230v231-2022-12-06) [Compare Source](https://togithub.com/googleapis/api-common-java/compare/v2.2.2...v2.3.1) ##### Bug Fixes - Build with JDK11 and target JDK8 ([1862611](https://togithub.com/googleapis/api-common-java/commit/1862611d8b5cff69288380fe567e6ce033148c55)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
Added log statements and setup in autoconfig class. Some common methods were put in Util in case they have to be reused