Documentation ¶
Overview ¶
Package stackdriver provides a cloud monitoring sink for applications instrumented with the go-metrics library.
Index ¶
- func DefaultBucketer(key []string) []float64
- func DefaultLabelExtractor(key []string, kind string) ([]string, []metrics.Label, error)
- type BucketFn
- type Config
- type ExtractLabelsFn
- type Logger
- type Sink
- func (s *Sink) AddSample(key []string, val float32)
- func (s *Sink) AddSampleWithLabels(key []string, val float32, labels []metrics.Label)
- func (s *Sink) Close(ctx context.Context) error
- func (s *Sink) EmitKey(key []string, val float32)
- func (s *Sink) IncrCounter(key []string, val float32)
- func (s *Sink) IncrCounterWithLabels(key []string, val float32, labels []metrics.Label)
- func (s *Sink) ResetCounter(key []string)
- func (s *Sink) ResetCounterWithLabels(key []string, labels []metrics.Label)
- func (s *Sink) SetGauge(key []string, val float32)
- func (s *Sink) SetGaugeWithLabels(key []string, val float32, labels []metrics.Label)
- func (s *Sink) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBucketer ¶
DefaultBucketer is the default BucketFn used to determing bucketing values for metrics.
func DefaultLabelExtractor ¶ added in v0.2.0
DefaultLabelExtractor is the default ExtractLabelsFn and is a direct passthrough. Counter and Gauge metrics are renamed to include the type in their name to avoid duplicate metrics with the same name but different types (which is allowed by go-metrics but not by Stackdriver).
Types ¶
type Config ¶
type Config struct { // The Google Cloud Project ID to publish metrics to. // Optional. GCP instance metadata is used to determine the ProjectID if // not set. ProjectID string // The label extractor provides a way to rewrite metric key into a new key // with multiple labels. This is useful if the instrumented code includes // variable parameters within a metric name. // Optional. Defaults to DefaultLabelExtractor. LabelExtractor ExtractLabelsFn // Prefix of the metrics recorded. Defaults to "go-metrics/" so a metric // "foo" will be recorded as "custom.googleapis.com/go-metrics/foo". Prefix *string // The bucketer is used to determine histogram bucket boundaries // for the sampled metrics. This will execute before the LabelExtractor. // Optional. Defaults to DefaultBucketer. Bucketer BucketFn // The interval between sampled metric points. Must be > 1 minute. // https://cloud.google.com/monitoring/custom-metrics/creating-metrics#writing-ts // Optional. Defaults to 1 minute. ReportingInterval time.Duration // The location of the running task. See: // https://cloud.google.com/monitoring/api/resources#tag_generic_task // Optional. GCP instance metadata is used to determine the location, // otherwise it defaults to 'global'. Location string // The namespace for the running task. See: // https://cloud.google.com/monitoring/api/resources#tag_generic_task // Optional. Defaults to 'default'. Namespace string // The job name for the running task. See: // https://cloud.google.com/monitoring/api/resources#tag_generic_task // Optional. Defaults to the running program name. Job string // The task ID for the running task. See: // https://cloud.google.com/monitoring/api/resources#tag_generic_task // Optional. Defaults to a combination of hostname+pid. TaskID string // Debug logging. Errors are always logged to stderr, but setting this to // true will log additional information that is helpful when debugging // errors. // Optional. Defaults to false. DebugLogs bool // MonitoredResource identifies the machine/service/resource that is // monitored. Different possible settings are defined here: // https://cloud.google.com/monitoring/api/resources // // Setting a nil MonitoredResource will run a defaultMonitoredResource // function. MonitoredResource *monitoredrespb.MonitoredResource // Logger that can be injected for custom log formatting. Logger Logger }
Config options for the stackdriver Sink.
type ExtractLabelsFn ¶ added in v0.2.0
ExtractLabelsFn converts a given metric name and type into a new metric name and optionally additional labels. Errors will prevent the metric from writing to stackdriver.
type Logger ¶ added in v0.3.0
type Logger interface { Printf(format string, v ...interface{}) Println(v ...interface{}) }
Logger is the log interface used in go-metrics-stackdriver
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink conforms to the metrics.MetricSink interface and is used to transmit metrics information to stackdriver.
Sink performs in-process aggregation of metrics to limit calls to stackdriver.
func NewSink ¶
func NewSink(client *monitoring.MetricClient, config *Config) *Sink
NewSink creates a Sink to flush metrics to stackdriver every interval. The interval should be greater than 1 minute.
func (*Sink) AddSampleWithLabels ¶
AddSampleWithLabels adds a sample to a histogram metric.
func (*Sink) IncrCounter ¶
IncrCounter increments a counter by a value.
func (*Sink) IncrCounterWithLabels ¶
IncrCounterWithLabels increments a counter by a value.
func (*Sink) ResetCounter ¶ added in v0.6.0
ResetCounter resets a counter to zero
func (*Sink) ResetCounterWithLabels ¶ added in v0.6.0
ResetCounterWithLabels resets a counter to zero
func (*Sink) SetGaugeWithLabels ¶
SetGaugeWithLabels retains the last value it is set to.
Directories ¶
Path | Synopsis |
---|---|
Package vault provides helper functions to improve the go-metrics to stackdriver metric conversions specific to HashiCorp Vault.
|
Package vault provides helper functions to improve the go-metrics to stackdriver metric conversions specific to HashiCorp Vault. |