datadog

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Example (DatadogTracker)
package main

import (
	"fmt"
	"log"
	"net/http"
	"time"

	"github.com/bukalapak/ottoman/tracker/datadog"
)

func main() {
	tc := datadog.New("service_name",
		"this api key is secret",
		datadog.Option{
			Transport: http.DefaultTransport,
			Timeout:   time.Second * 1,
		})
	payload := datadog.Series{
		Series: []datadog.Metric{
			{
				Metric: "service_name.command.call",
				Type:   datadog.Count,
				Points: [][2]int64{{time.Now().Unix(), 1}},
				Tags: []string{
					"environment:production",
					"version:1",
					"sub_command:mock",
				},
			},
		},
	}
	resp, err := tc.Track(payload)
	if err != nil {
		log.Println(err)
	}
	fmt.Println(resp)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datadog

type Datadog struct {
	ServiceName string
	// contains filtered or unexported fields
}

Datadog is a client for request to datadog's endpoint

func New

func New(serviceName, apiKey string, option Option) *Datadog

New returns a datadog client with a custom http client

func (*Datadog) Track

func (dd *Datadog) Track(payload interface{}) ([]byte, error)

type Metric

type Metric struct {
	Metric   string     `json:"metric,omitempty" validate:"required"`
	Points   [][2]int64 `json:"points,omitempty" validate:"required"`
	Type     Type       `json:"type,omitempty"`
	Interval int64      `json:"interval,omitempty"`
	Host     string     `json:"host,omitempty"`
	Tags     []string   `json:"tags,omitempty"`
}

DatadogMetric represent single metric of series

type Option

type Option struct {
	Transport http.RoundTripper
	Timeout   time.Duration
}

Option is the configuration option for the Datadog tracker.

type Series

type Series struct {
	Series []Metric `json:"series"`
}

Series represent time-series data that can be graphed on Datadog’s dashboards Further information can be accessed on https://docs.datadoghq.com/api/?lang=bash#post-timeseries-points

type Type

type Type string
const (
	Count Type = "count"
	Rate  Type = "rate"
	Gauge Type = "gauge"
)

Jump to

Keyboard shortcuts

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