Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ test)
RETURN_CODE=$?
;;
lint)
mvn \
-Penable-samples \
com.coveo:fmt-maven-plugin:check
mvn com.coveo:fmt-maven-plugin:check
RETURN_CODE=$?
;;
javadoc)
Expand Down
80 changes: 80 additions & 0 deletions .readme-partials.yaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
"groupName": "jackson dependencies"
}
],
"semanticCommits": true
"semanticCommits": true,
"masterIssue": true
}
4 changes: 2 additions & 2 deletions synth.metadata
Original file line number Diff line number Diff line change
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