datadog

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 8 Imported by: 1

README

datadog-client

do not use in production

a wrapper over the datadog-go/statsd which can reconnect when a connection is lost

Example

$ go get -u github.com/deissh/datadog-client
package main

import (
	dc "github.com/deissh/datadog-client"
	"time"
)

func main() {
	// creating new connection to 127.0.0.1:8125
	dc.InitializeClient()
	// set prefix to all events, messages, metrics and etc
	dc.SetPrefix("someprefix_")
	// set tags
	dc.AddTag("debug", "true")
	dc.AddTag("version", "v1.2.3")
	
	// creating a gauge task that will running every minute
	dc.RunGaugeTask(
		"user_online",
		time.Minute,
		dc.Tags{},
		func() (f float64, err error) {
			return 5, err
		},
	)
	
	// start client updater
	dc.Start()
	// or run in goroutine dc.Start()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTag

func AddTag(name, value string)

func Gauge

func Gauge(name string, value float64, tags ...Tags)

Gauge Stored as a GAUGE type in DataDog. Each value in the stored time-series is the last gauge value submitted for the metric during the StatsD flush period.

func InitializeClient

func InitializeClient()

func NewClient

func NewClient() *statsd.Client

func RunGaugeTask

func RunGaugeTask(name string, duration time.Duration, tags Tags, exec func() (float64, error))

RunGaugeTask every duration and send value as Gauge

func SendEvent

func SendEvent(event Event, tags ...Tags)

SendEvent represents any record of activity noteworthy for engineers (devs, ops, and security).

func SetPrefix

func SetPrefix(value string)

func Start

func Start()

Types

type Event

type Event struct {
	// Title of the event.  Required.
	Title string
	// Text is the description of the event.  Required.
	Text string
	// AggregationKey groups this event with others of the same key.
	AggregationKey string
	// Priority of the event.  Can be statsd.Low or statsd.Normal.
	Priority statsd.EventPriority
	// SourceTypeName is a source type for the event.
	SourceTypeName string
	// AlertType can be statsd.Info, statsd.Error, statsd.Warning, or statsd.Success.
	// If absent, the default value applied by the dogstatsd server is Info.
	AlertType statsd.EventAlertType
}

type Tags

type Tags map[string]string

func (Tags) StringSlice

func (tags Tags) StringSlice() []string

Jump to

Keyboard shortcuts

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