metrics

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(clients ...*MetricsClient)

func EmitCounter

func EmitCounter(name string, value float64, tags map[string]string) error

func EmitGauge

func EmitGauge(name string, value float64, tags map[string]string) error

func EmitTimer

func EmitTimer(name string, value float64, tags map[string]string) error

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 Config

type Config struct {
	// contains filtered or unexported fields
}

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 (mc *MetricsClient) EmitCounter(name string, value float64, tags map[string]string) error

func (*MetricsClient) EmitGauge

func (mc *MetricsClient) EmitGauge(name string, value float64, tags map[string]string) error

func (*MetricsClient) EmitTimer

func (mc *MetricsClient) EmitTimer(name string, value float64, tags map[string]string) error

func (*MetricsClient) Start

func (mc *MetricsClient) Start()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL