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

feat(log): added log statements to gend autocfg #1053

Merged
merged 5 commits into from
Oct 22, 2022

Conversation

diegomarquezp
Copy link
Contributor

Added log statements and setup in autoconfig class. Some common methods were put in Util in case they have to be reused

@diegomarquezp diegomarquezp requested review from a team as code owners October 3, 2022 22:11
@diegomarquezp diegomarquezp force-pushed the autoconfig-gen-draft2-logger branch from e1e4b56 to fa7963e Compare October 3, 2022 22:21
Copy link
Contributor

@zhumin8 zhumin8 left a 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.

+ " }\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"
Copy link
Contributor

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"
Copy link
Contributor

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) {
Copy link
Contributor

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.

@emmileaf emmileaf added the spring pr that's related to spring code gen, intend to merge into autoconfig-gen-draft2 branch. label Oct 4, 2022
@diegomarquezp diegomarquezp force-pushed the autoconfig-gen-draft2-logger branch from 3579b7c to 854f34a Compare October 5, 2022 17:54
@diegomarquezp diegomarquezp force-pushed the autoconfig-gen-draft2-logger branch from 8832d0c to 28269bd Compare October 12, 2022 20:22
Copy link
Contributor

@emmileaf emmileaf left a 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
@diegomarquezp diegomarquezp force-pushed the autoconfig-gen-draft2-logger branch from 0a0c92b to 5041b71 Compare October 22, 2022 22:03
@diegomarquezp diegomarquezp merged commit 1818d0b into autoconfig-gen-draft2 Oct 22, 2022
@diegomarquezp diegomarquezp deleted the autoconfig-gen-draft2-logger branch October 22, 2022 22:04
@sonarqubecloud
Copy link

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 14 Code Smells

95.7% 95.7% Coverage
0.0% 0.0% Duplication

diegomarquezp added a commit that referenced this pull request Oct 23, 2022
* 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
zhumin8 added a commit that referenced this pull request Nov 21, 2022
…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.
suztomo pushed a commit that referenced this pull request Mar 21, 2023
[![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#&#8203;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-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spring pr that's related to spring code gen, intend to merge into autoconfig-gen-draft2 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants