gcp

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package gcp provides customization for the application runtime environment on Google Cloud Platform.

It focuses on managed services provided in Google Cloud's operations, which includes:

Usage

It's used as parameter for nilgo.Run. Following code enables all supported services.

nilgo.Run(
  gcp.Options(
    gcp.WithService("app"),
    gcp.WithVersion("v0.1.0"),
    gcp.WithProfiler(),
  ),
  ...
)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Options

func Options(opts ...Option) []interface{}

Options generates customized configuration with provided options.

By default, only logging and error reporting are configured. monitoring, trace, and profiler need to enable explicitly using corresponding functional Option.

It returns nil if Google Cloud project ID is neither found nor provided via WithProject.

Types

type Option

type Option func(*options)

Option configures the application runtime environment on Google Cloud Platform.

func WithMetric

func WithMetric(opts ...metric.Option) Option

WithMetric starts OpenTelemetry meter with Google Cloud Monitoring exporter.

See https://cloud.google.com/monitoring.

To enable metric, the service account runs the application need to have IAM roles/monitoring.metricWriter. See https://cloud.google.com/monitoring/access-control#predefined_roles.

func WithProfiler

func WithProfiler(opts ...option.ClientOption) Option

WithProfiler starts a client of Google Cloud profiler.

See https://cloud.google.com/profiler.

To enable profiler, the service account runs the application need to have IAM roles/cloudprofiler.agent. See https://cloud.google.com/profiler/docs/iam#roles.

func WithProject

func WithProject(project string) Option

WithProject provides the Google Cloud project ID to use instead of the one set by GOOGLE_CLOUD_PROJECT environment variable or read from the metadata server.

Set this if it's running in anywhere else outside of Google Cloud Platform.

func WithService

func WithService(name string) Option

WithService provides service name to use instead of the one parse from build info or executable name.

func WithTrace

func WithTrace(opts ...trace.Option) Option

WithTrace starts OpenTelemetry trace with Google Cloud Trace exporter.

See https://cloud.google.com/trace.

To enable trace, the service account runs the application need to have IAM roles/cloudtrace.agent. See https://cloud.google.com/trace/docs/iam#roles.

func WithVersion added in v0.3.0

func WithVersion(version string) Option

WithVersion provides service version to use instead of the one parse from build info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL