Skip to content

Commit

Permalink
chore: update common templates (#251)
Browse files Browse the repository at this point in the history
* ci(java): switch to GitHub Actions

* ci: switch to GitHub Actions

* update based on comment

Source-Author: Stephanie Wang <stephaniewang526@users.noreply.github.com>
Source-Date: Mon May 11 12:54:00 2020 -0400
Source-Repo: googleapis/synthtool
Source-Sha: 55cdc844877d97139f25004229842624a6a86a02
Source-Link: googleapis/synthtool@55cdc84

* chore: move ci.yaml to workflows dir

Source-Author: Stephanie Wang <stephaniewang526@users.noreply.github.com>
Source-Date: Mon May 11 16:24:04 2020 -0400
Source-Repo: googleapis/synthtool
Source-Sha: 98c50772ec23295c64cf0d2ddf199ea52961fd4c
Source-Link: googleapis/synthtool@98c5077

* docs: update CONTRIBUTING.md to include code formatting

Co-authored-by: Jeff Ching <chingor@google.com>
Co-authored-by: Jeffrey Rennie <rennie@google.com>

Source-Author: Brian Chen <chenbrian@google.com>
Source-Date: Tue May 12 10:24:59 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 5b48b0716a36ca069db3038da7e205c87a22ed19
Source-Link: googleapis/synthtool@5b48b07

* chore(java_templates): add default CODEOWNERS files for samples reviews

This should automatically request reviews from the googleapis/java-samples-reviewers team for changes to samples Java code.

If you provide a `codeowner_team` in the `.repo-metadata.json` configuration file, it also adds an entry for any Java code. Note that later entries in the file take precedence over earlier ones so samples Java code will only require reviews by the samples team.

Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Wed Jun 3 15:32:11 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 8b65daa222d193b689279162781baf0aa1f0ffd2
Source-Link: googleapis/synthtool@8b65daa

* chore: turn on renovate-bot master issue for java repos

Source-Author: Stephanie Wang <stephaniewang526@users.noreply.github.com>
Source-Date: Thu Jun 4 18:23:16 2020 -0400
Source-Repo: googleapis/synthtool
Source-Sha: cac9eef310652bf138dd76b716e4986e757d62ac
Source-Link: googleapis/synthtool@cac9eef

* build(java): skip lint on samples directory

Let the samples test decide how to enforce linting

Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Fri Jun 5 13:40:10 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 987270824bd26f6a8c716d5e2022057b8ae7b26e
Source-Link: googleapis/synthtool@9872708

* chore: restore README content

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
yoshi-automation and chingor13 committed Jun 11, 2020
1 parent bcac2d3 commit 0e58788
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 40 deletions.
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,8 @@
# Code owners file.
# This file controls who is tagged for review for any given pull request.

# For syntax help see:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax

# The java-samples-reviewers team is the default owner for samples changes
samples/**/*.java @googleapis/java-samples-reviewers
76 changes: 76 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,76 @@
on:
push:
branches:
- master
pull_request:
name: ci
jobs:
units:
runs-on: ubuntu-latest
strategy:
matrix:
java: [7, 8, 11]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{matrix.java}}
- run: java -version
- run: .kokoro/build.sh
env:
JOB_TYPE: test
- name: coverage
uses: codecov/codecov-action@v1
with:
name: actions ${{matrix.java}}
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
- run: .kokoro/build.bat
env:
JOB_TYPE: test
dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
- run: .kokoro/dependencies.sh
linkage-monitor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
- run: .kokoro/linkage-monitor.sh
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
- run: .kokoro/build.sh
env:
JOB_TYPE: lint
clirr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: java -version
- run: .kokoro/build.sh
env:
JOB_TYPE: clirr
2 changes: 1 addition & 1 deletion .kokoro/build.bat
@@ -1,3 +1,3 @@
:: See documentation in type-shell-output.bat

"C:\Program Files\Git\bin\bash.exe" github/java-spanner/.kokoro/build.sh
"C:\Program Files\Git\bin\bash.exe" %~dp0build.sh
80 changes: 80 additions & 0 deletions .readme-partials.yaml
Expand Up @@ -40,3 +40,83 @@ custom_content: |
#### Complete source code
In [DatabaseSelect.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/spanner/snippets/DatabaseSelect.java) we put together all the code shown above in a single program.
## OpenCensus Metrics
Cloud Spanner client supports [Opencensus Metrics](https://opencensus.io/stats/),
which gives insight into the client internals and aids in debugging/troubleshooting
production issues. OpenCensus metrics will provide you with enough data to enable you to
spot, and investigate the cause of any unusual deviations from normal behavior.
All Cloud Spanner Metrics are prefixed with `cloud.google.com/java/spanner/`. The
metrics will be tagged with:
* `database`: the target database name.
* `instance_id`: the instance id of the target Spanner instance.
* `client_id`: the user defined database client id.
* `library_version`: the version of the library that you're using.
> Note: RPC level metrics can be gleaned from gRPC’s metrics, which are prefixed
with `grpc.io/client/`.
### Available client-side metrics:
* `cloud.google.com/java/spanner/max_in_use_sessions`: This returns the maximum
number of sessions that have been in use during the last maintenance window
interval, so as to provide an indication of the amount of activity currently
in the database.
* `cloud.google.com/java/spanner/max_allowed_sessions`: This shows the maximum
number of sessions allowed.
* `cloud.google.com/java/spanner/in_use_sessions`: This metric allows users to
see instance-level and database-level data for the total number of sessions in
use (or checked out from the pool) at this very moment.
* `cloud.google.com/java/spanner/num_acquired_sessions`: This metric allows
users to see the total number of acquired sessions.
* `cloud.google.com/java/spanner/num_released_sessions`: This metric allows
users to see the total number of released (destroyed) sessions.
* `cloud.google.com/java/spanner/get_session_timeouts`: This gives you an
indication of the total number of get session timed-out instead of being
granted (the thread that requested the session is placed in a wait queue where
it waits until a session is released into the pool by another thread) due to
pool exhaustion since the server process started.
If you are using Maven, add this to your pom.xml file
```xml
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-impl</artifactId>
<version>0.26.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-exporter-stats-stackdriver</artifactId>
<version>0.26.0</version>
</dependency>
```
If you are using Gradle, add this to your dependencies
```Groovy
compile 'io.opencensus:opencensus-impl:0.26.0'
compile 'io.opencensus:opencensus-exporter-stats-stackdriver:0.26.0'
```
At the start of your application configure the exporter:
```java
import io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter;
// Enable OpenCensus exporters to export metrics to Stackdriver Monitoring.
// Exporters use Application Default Credentials to authenticate.
// See https://developers.google.com/identity/protocols/application-default-credentials
// for more details.
// The minimum reporting period for Stackdriver is 1 minute.
StackdriverStatsExporter.createAndRegister();
```
By default, the functionality is disabled. You need to include opencensus-impl
dependency to collect the data and exporter dependency to export to backend.
[Click here](https://medium.com/google-cloud/troubleshooting-cloud-spanner-applications-with-opencensus-2cf424c4c590) for more information.
11 changes: 10 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -99,7 +99,16 @@ mvn -Penable-samples clean verify
```

2. [Activate](#profile-activation) the profile.
3. Define your samples in a normal Maven project in the `samples/` directory
3. Define your samples in a normal Maven project in the `samples/` directory.

### Code Formatting

Code in this repo is formatted with
[google-java-format](https://github.com/google/google-java-format).
To run formatting on your project, you can run:
```
mvn com.coveo:fmt-maven-plugin:format
```

### Profile Activation

Expand Down
67 changes: 32 additions & 35 deletions README.md
Expand Up @@ -131,28 +131,11 @@ try {

In [DatabaseSelect.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/spanner/snippets/DatabaseSelect.java) we put together all the code shown above in a single program.





## Troubleshooting

To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting].

## Transport

Cloud Spanner uses gRPC for the transport layer.

## Java Versions

Java 7 or above is required for using this client.


## OpenCensus Metrics

Cloud Spanner client supports [Opencensus Metrics](https://opencensus.io/stats/),
which gives insight into the client internals and aids in debugging/troubleshooting
production issues. OpenCensus metrics will provide you with enough data to enable you to
which gives insight into the client internals and aids in debugging/troubleshooting
production issues. OpenCensus metrics will provide you with enough data to enable you to
spot, and investigate the cause of any unusual deviations from normal behavior.

All Cloud Spanner Metrics are prefixed with `cloud.google.com/java/spanner/`. The
Expand All @@ -162,35 +145,34 @@ metrics will be tagged with:
* `client_id`: the user defined database client id.
* `library_version`: the version of the library that you're using.

> Note: RPC level metrics can be gleaned from gRPC’s metrics, which are prefixed
> Note: RPC level metrics can be gleaned from gRPC’s metrics, which are prefixed
with `grpc.io/client/`.

### Available client-side metrics:

* `cloud.google.com/java/spanner/max_in_use_sessions`: This returns the maximum
number of sessions that have been in use during the last maintenance window
interval, so as to provide an indication of the amount of activity currently
* `cloud.google.com/java/spanner/max_in_use_sessions`: This returns the maximum
number of sessions that have been in use during the last maintenance window
interval, so as to provide an indication of the amount of activity currently
in the database.

* `cloud.google.com/java/spanner/max_allowed_sessions`: This shows the maximum
* `cloud.google.com/java/spanner/max_allowed_sessions`: This shows the maximum
number of sessions allowed.

* `cloud.google.com/java/spanner/in_use_sessions`: This metric allows users to
see instance-level and database-level data for the total number of sessions in
use (or checked out from the pool) at this very moment.
use (or checked out from the pool) at this very moment.

* `cloud.google.com/java/spanner/num_acquired_sessions`: This metric allows
* `cloud.google.com/java/spanner/num_acquired_sessions`: This metric allows
users to see the total number of acquired sessions.

* `cloud.google.com/java/spanner/num_released_sessions`: This metric allows
* `cloud.google.com/java/spanner/num_released_sessions`: This metric allows
users to see the total number of released (destroyed) sessions.

* `cloud.google.com/java/spanner/get_session_timeouts`: This gives you an
indication of the total number of get session timed-out instead of being
granted (the thread that requested the session is placed in a wait queue where
it waits until a session is released into the pool by another thread) due to
* `cloud.google.com/java/spanner/get_session_timeouts`: This gives you an
indication of the total number of get session timed-out instead of being
granted (the thread that requested the session is placed in a wait queue where
it waits until a session is released into the pool by another thread) due to
pool exhaustion since the server process started.

If you are using Maven, add this to your pom.xml file
```xml
<dependency>
Expand All @@ -215,7 +197,6 @@ At the start of your application configure the exporter:

```java
import io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter;

// Enable OpenCensus exporters to export metrics to Stackdriver Monitoring.
// Exporters use Application Default Credentials to authenticate.
// See https://developers.google.com/identity/protocols/application-default-credentials
Expand All @@ -224,11 +205,27 @@ import io.opencensus.exporter.stats.stackdriver.StackdriverStatsExporter;
StackdriverStatsExporter.createAndRegister();
```

By default, the functionality is disabled. You need to include opencensus-impl
By default, the functionality is disabled. You need to include opencensus-impl
dependency to collect the data and exporter dependency to export to backend.

[Click here](https://medium.com/google-cloud/troubleshooting-cloud-spanner-applications-with-opencensus-2cf424c4c590) for more information.





## Troubleshooting

To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting].

## Transport

Cloud Spanner uses gRPC for the transport layer.

## Java Versions

Java 7 or above is required for using this client.

## Versioning


Expand Down
3 changes: 2 additions & 1 deletion renovate.json
Expand Up @@ -76,5 +76,6 @@
"groupName": "jackson dependencies"
}
],
"semanticCommits": true
"semanticCommits": true,
"masterIssue": true
}
4 changes: 2 additions & 2 deletions synth.metadata
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/java-spanner.git",
"sha": "87049575c14a4b954b49a25620ef7ada4738c1a6"
"sha": "13e47c305c1f546e0ae54ca1deb7faabd6eb9ea9"
}
},
{
Expand All @@ -19,7 +19,7 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "716f741f2d307b48cbe8a5bc3bc883571212344a"
"sha": "987270824bd26f6a8c716d5e2022057b8ae7b26e"
}
}
],
Expand Down

0 comments on commit 0e58788

Please sign in to comment.