Categorygithub.com/maloneya/go-metrics-stackdriver
modulepackage
0.0.1
Repository: https://github.com/maloneya/go-metrics-stackdriver.git
Documentation: pkg.go.dev

# README

go-metrics-stackdriver

godoc

This library provides a stackdriver sink for applications instrumented with the go-metrics library.

Why did i fork this?

I want to experiment with client side windowed counters and delta type metrics

Details

stackdriver.NewSink's return value satisfies the go-metrics library's MetricSink interface. When providing a stackdriver.Sink to libraries and applications instrumented against MetricSink, the metrics will be aggregated within this library and written to stackdriver as Generic Task timeseries metrics.

Example

import "github.com/google/go-metrics-stackdriver"
...
client, _ := monitoring.NewMetricClient(context.Background())
ss := stackdriver.NewSink(client, &stackdriver.Config{
  ProjectID: projectID,
})
...
ss.SetGauge([]string{"foo"}, 42)
ss.IncrCounter([]string{"baz"}, 1)
ss.AddSample([]string{"method", "const"}, 200)

The full example can be run from a cloud shell console to test how metrics are collected and displayed.

You can also try out the example using Cloud Run!

Run on Google Cloud

# Packages

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.
Package vault provides helper functions to improve the go-metrics to stackdriver metric conversions specific to HashiCorp Vault.

# Functions

DefaultBucketer is the default BucketFn used to determing bucketing values for metrics.
DefaultLabelExtractor is the default ExtractLabelsFn and is a direct passthrough.
NewSink creates a Sink to flush metrics to stackdriver every interval.

# Structs

Config options for the stackdriver Sink.
Sink conforms to the metrics.MetricSink interface and is used to transmit metrics information to stackdriver.

# Interfaces

Logger is the log interface used in go-metrics-stackdriver.

# Type aliases

BucketFn returns the histogram bucket thresholds based on the given metric name.
ExtractLabelsFn converts a given metric name and type into a new metric name and optionally additional labels.