README ¶
APMInsight Server SDK Golang
Installation
Get the code with:
go get github.com/volcengine/apminsight-server-sdk-go
recommend go >= 1.13.1
Usage
see CODE EXAMPLE
Build Client
create a new client:
client := metrics.NewMetricClient(metrics.WithPrefix("your metric common prefix"))
client.Close()
or init with default client:
metrics.Init(metrics.WithPrefix("your metric common prefix"))
metrics.Close()
Metrics
emit with your client
//without tags
client.EmitCounter("example_counter_metric", 1, nil)
client.EmitTimer("example_timer_metric", 1000, nil)
client.EmitGauge("example_gauge_metric", 100, nil)
//with tags
tags := map[string]string{
"tagKey": "tagValue",
}
client.EmitCounter("example_counter_metric", 1, tags)
client.EmitTimer("example_timer_metric", 1000, tags)
client.EmitGauge("example_gauge_metric", 100, tags)
or emit with default client
//without tags
metrics.EmitCounter("example_counter_metric", 1, nil)
metrics.EmitTimer("example_timer_metric", 1000, nil)
metrics.EmitGauge("example_gauge_metric", 100, nil)
//with tags
tags := map[string]string{
"tagKey": "tagValue",
}
metrics.EmitCounter("example_counter_metric", 1, tags)
metrics.EmitTimer("example_timer_metric", 1000, tags)
metrics.EmitGauge("example_gauge_metric", 100, tags)
Configuration
you can config client with metrics.WithXXX(value)
Documentation ¶
Index ¶
- func Close(clients ...*MetricsClient)
- func EmitCounter(name string, value float64, tags map[string]string) error
- func EmitGauge(name string, value float64, tags map[string]string) error
- func EmitTimer(name string, value float64, tags map[string]string) error
- func Init(options ...ClientOption)
- func SetLogFunc(_logfunc func(string, ...interface{}))
- type ClientOption
- type Config
- type MetricsClient
- func (mc *MetricsClient) Close()
- func (mc *MetricsClient) EmitCounter(name string, value float64, tags map[string]string) error
- func (mc *MetricsClient) EmitGauge(name string, value float64, tags map[string]string) error
- func (mc *MetricsClient) EmitTimer(name string, value float64, tags map[string]string) error
- func (mc *MetricsClient) Start()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close(clients ...*MetricsClient)
func Init ¶
func Init(options ...ClientOption)
func SetLogFunc ¶
func SetLogFunc(_logfunc func(string, ...interface{}))
Types ¶
type ClientOption ¶
type ClientOption func(config *Config)
func WithAddress ¶
func WithAddress(address string) ClientOption
func WithPrefix ¶
func WithPrefix(prefix string) ClientOption
type MetricsClient ¶
type MetricsClient struct {
// contains filtered or unexported fields
}
func NewMetricClient ¶
func NewMetricClient(options ...ClientOption) *MetricsClient
func (*MetricsClient) Close ¶
func (mc *MetricsClient) Close()
func (*MetricsClient) EmitCounter ¶
func (*MetricsClient) Start ¶
func (mc *MetricsClient) Start()
Click to show internal directories.
Click to hide internal directories.