Documentation
¶
Overview ¶
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func DefaultBucketer(key []string) []float64
- func DefaultLabelExtractor(key []string, kind string) ([]string, []metrics.Label, error)
- type BucketFn
- type Config
- type ExtractLabelsFn
- type Sink
- func (s *Sink) AddSample(key []string, val float32)
- func (s *Sink) AddSampleWithLabels(key []string, val float32, labels []metrics.Label)
- 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) SetGauge(key []string, val float32)
- func (s *Sink) SetGaugeWithLabels(key []string, val float32, labels []metrics.Label)
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 // 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 will be logged to stderr, but setting this to true // will log additional information that is helpful when debugging errors. // Optional. Defaults to false. DebugLogs bool }
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 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 ¶
Samples are for timing information, where quantiles are used.
func (*Sink) IncrCounter ¶
Counters should accumulate values.
func (*Sink) IncrCounterWithLabels ¶
Counters should accumulate values.