compile 'io.micronaut.gcp:micronaut-gcp-common:1.1.0'
Micronaut GCP
Provides integration between Micronaut and Google Cloud Platform (GCP)
Version: 1.1.0
1 Introduction
This project provides various extensions to Micronaut to integrate Micronaut with Google Cloud Platform (GCP).
2 Setting up GCP Support
The micronaut-gcp-common
module includes basic setup for running applications on Google Cloud.
<dependency>
<groupId>io.micronaut.gcp</groupId>
<artifactId>micronaut-gcp-common</artifactId>
<version>1.1.0</version>
</dependency>
Prerequisites:
-
You should have a Google Cloud Platform project created
-
Configure default project
gcloud config set project YOUR_PROJECT_ID
-
Authenticate with
gcloud auth login
-
Authenticate application default credential with
gcloud auth application-default login
It’s strongly recommended that you use a Service Account for your application.
Google Project ID
The module features a base GoogleCloudConfiguration which you can use to configure or retrieve the GCP Project ID:
Property | Type | Description |
---|---|---|
|
java.lang.String |
Sets the project id to use. |
You can inject this bean and use the getProjectId()
method to retrieve the configured or detected project ID.
Google Credentials
The module will setup a bean of exposing the com.google.auth.oauth2.GoogleCredentials
instance that are either detected from the local environment or configured by GoogleCredentialsConfiguration:
Property | Type | Description |
---|---|---|
|
java.util.List |
The default scopes to associate with the application to access specific APIs. See <a href="https://developers.google.com/identity/protocols/googlescopes">Google Scopes</a> for a complete list. Leave this empty if you don’t need additional API access. |
|
java.lang.String |
Sets the Base64 encoded service account key content.. |
|
java.lang.String |
Sets the location to the service account credential key file. |
3 Stackdriver Trace
The micronaut-gcp-tracing
integrates Micronaut with Stackdriver Trace.
To enable it add the following dependency:
compile 'io.micronaut.gcp:micronaut-gcp-tracing:1.1.0'
<dependency>
<groupId>io.micronaut.gcp</groupId>
<artifactId>micronaut-gcp-tracing</artifactId>
<version>1.1.0</version>
</dependency>
Then enabling Zipkin tracing in your configuration application.yml
:
tracing:
zipkin:
enabled: true
# [Optional] Set sampling probability to 100% for dev/testing purposes to observe traces.
#
# sampler:
# probability=1.0
# [Optional] configuration to enable/disable Stackdriver Trace configuration.
# This is defaulted to true.
#
# gcp:
# tracing:
# enabled: true