observe

package
Version: v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Overview

Package observe provides functions that help with setting tracing/metrics in cloud providers, mainly GCP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCloudRunInfo added in v1.3.1

func GetCloudRunInfo() (service, version, config string)

GetCloudRunInfo returns the service and the version of the Cloud Run application.

func GetGAEInfo

func GetGAEInfo() (service, version string)

GetGAEInfo returns the service and the version of the GAE application.

func GetServiceInfo

func GetServiceInfo() (projectID, service, version string)

GetServiceInfo returns the GCP Project ID, the service name and version (GAE or through SERVICE_NAME/SERVICE_VERSION env vars). Note that SERVICE_NAME/SERVICE_VERSION are not standard but your application can pass them in as variables to be included in your trace attributes

func GoogleProjectID

func GoogleProjectID() string

GoogleProjectID returns the GCP Project ID that can be used to instantiate various GCP clients such as Stack Driver.

func IsCloudRun added in v1.3.1

func IsCloudRun() bool

IsCloudRun tells you whether your program is running within the Cloud Run platform.

func IsGAE

func IsGAE() bool

IsGAE tells you whether your program is running within the App Engine platform.

func IsGCPEnabled

func IsGCPEnabled() bool

IsGCPEnabled returns whether the running application is inside GCP, has access to its products or Stackdriver integration was not disabled.

func NewDatadogExporter added in v1.3.6

func NewDatadogExporter(config DatadogExporterConfig, onErr func(error)) (*datadog.Exporter, error)

NewDatadogExporter will return Datadog's opencensus exporter if it's enabled (through DATADOG_EXPORTER_ENABLED env variable). When the exporter is disabled, it will return nil. Exporter will send metrics and traces to Datadog's agent using addresses specified through DatadogExporterConfig

func NewStackdriverExporter

func NewStackdriverExporter(projectID string, onErr func(error)) (*stackdriver.Exporter, error)

NewStackdriverExporter will return the tracing and metrics through the stack driver exporter, if exists in the underlying platform. If exporter is registered, it returns the exporter so you can register it and ensure to call Flush on termination.

func RegisterAndObserveGCP added in v1.2.8

func RegisterAndObserveGCP(onError func(error)) error

RegisterAndObserveGCP will initiate and register Stackdriver profiling and tracing and metrics in environments that pass the tests in the IsGCPEnabled function. All exporters will be registered using the information returned by the GetServiceInfo function. Tracing and metrics are enabled via OpenCensus exporters. See the OpenCensus documentation for instructions for registering additional spans and metrics.

func SkipObserve added in v1.2.8

func SkipObserve() bool

SkipObserve checks if the GIZMO_SKIP_OBSERVE environment variable has been populated. This may be used along with local development to cut down on long startup times caused by the 'monitoredresource.Autodetect()' call in IsGCPEnabled().

Types

type DatadogExporterConfig added in v1.3.6

type DatadogExporterConfig struct {
	DatadogExporterEnabled        bool   `default:"false" split_words:"true"`
	DatadogExporterMetricsAddress string `split_words:"true"`
	DatadogExporterTracesAddress  string `split_words:"true"`
	DatadogExporterNamespace      string `default:"opencensus" split_words:"true"`
}

DatadogExporterConfig provides configuration for the Datadog exporter. Config can be initiated with envconfig from environment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL