ginwavefront

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 5 Imported by: 0

README

gin-wavefront

Go Report Card Godoc GitHub GitHub tag (latest SemVer)

gin-wavefront is a Gin middleware to emit metrics to Wavefront.

Prerequisites

To use this Gin middleware, you'll need to have

Installation

Using go get

go get github.com/retgits/gin-wavefront

Usage

To start, you'll need to initialize the Wavefront emitter:

wfconfig := &ginwavefront.WavefrontConfig{
    Server:        "https://<INSTANCE>.wavefront.com",
    Token:         "my-api-key",
    BatchSize:     10000,
    MaxBufferSize: 50000,
    FlushInterval: 1,
    Source:        "my-app",
    MetricPrefix:  "my.awesome.app",
    PointTags:     make(map[string]string),
}
wfemitter, err := ginwavefront.WavefrontEmitter(wfconfig)
if err != nil {
    fmt.Println(err.Error())
}

Now you can use the wfemitter as a middleware function in Gin

r := gin.New()
r.Use(wfemitter)

A complete sample app can be found in the examples folder

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

See the LICENSE file in the repository

Documentation

Overview

Package ginwavefront is a Gin middleware to emit metrics to Wavefront.

Index

Constants

View Source
const (
	// ErrCreateSender in case any errors occur while creating the Wavefront Direct Sender
	ErrCreateSender = "error creating wavefront sender: %s"
)

Variables

This section is empty.

Functions

func WavefrontEmitter

func WavefrontEmitter(w *WavefrontConfig) (gin.HandlerFunc, error)

WavefrontEmitter creates a new direct sender to Wavefront and returns a handlerfunc

Types

type WavefrontConfig

type WavefrontConfig struct {
	// Wavefront URL of the form https://<INSTANCE>.wavefront.com.
	Server string
	// Wavefront API token with direct data ingestion permission.
	Token string
	// Max batch of data sent per flush interval.
	BatchSize int
	// Max batch of data sent per flush interval.
	MaxBufferSize int
	// Interval (in seconds) at which to flush data to Wavefront.
	FlushInterval int
	// Map of Key-Value pairs (strings) associated with each data point sent to Wavefront.
	PointTags map[string]string
	// Name of the app that emits metrics.
	Source string
	// Prefix added to all metrics
	MetricPrefix string
}

WavefrontConfig configures the direct ingestion sender to Wavefront.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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