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:
- https://cloud.google.com/logging
- https://cloud.google.com/error-reporting
- https://cloud.google.com/monitoring
- https://cloud.google.com/trace
- https://cloud.google.com/profiler
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 ¶
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 ¶
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 ¶
WithService provides service name to use instead of the one parse from build info or executable name.
func WithTrace ¶
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
WithVersion provides service version to use instead of the one parse from build info.