metrics

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 24 Imported by: 139

README

Metrics

Metrics are supported to be pushed to both datadog and prometheus.

Datadog:

By default the cpu and heap profile are enabled, however any profile can be enabled by passing in a comma seperated DD_PROFILES using the names here

New Relic

Pass in the NEW_RELIC_LICENSE_KEY enviornment variable

Documentation

Overview

Package metrics implements a metrics dashboard with either datadog or prometheus (coming soon)

Index

Constants

View Source
const DDProfileEnv = "DD_PROFILES"

DDProfileEnv is the data daog profile neviornment variable.

View Source
const HandlerEnv = "METRICS_HANDLER"

HandlerEnv is the driver to use for metrics.

Variables

View Source
var AllHandlerTypes []HandlerType

AllHandlerTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.

Functions

func EthClient added in v0.0.19

func EthClient(ctx context.Context, metrics Handler, url string) (*ethclient.Client, error)

EthClient is a wrapper around ethclient.Client that adds metrics/tracing.

func Setup added in v0.0.19

func Setup(ctx context.Context, buildInfo config.BuildInfo) error

Setup sets up the global metrics handler. In general, we discourage globals but because of the ubiquitiy of global variables and the tangential nature of metrics, we allow this.

Types

type Handler added in v0.0.19

type Handler interface {
	Start(ctx context.Context) error
	// Gin gets a gin middleware for tracing.
	Gin() gin.HandlerFunc
	// ConfigureHTTPClient configures tracing on an http client
	ConfigureHTTPClient(client *http.Client)
	// AddGormCallbacks adds gorm callbacks for tracing.
	AddGormCallbacks(db *gorm.DB)
}

Handler collects metrics.

func Get added in v0.0.19

func Get() Handler

Get gets the global handler.

func NewDatadogMetricsHandler added in v0.0.19

func NewDatadogMetricsHandler(buildInfo config.BuildInfo) Handler

NewDatadogMetricsHandler creates a new datadog metrics handler.

func NewFromEnv added in v0.0.19

func NewFromEnv(ctx context.Context, buildInfo config.BuildInfo) (handler Handler, err error)

NewFromEnv sets up a metrics handler from environment variable. this will not set the global and generally, SetupFromEnv should be used instead.

func NewNullHandler added in v0.0.19

func NewNullHandler() Handler

NewNullHandler creates a new null transaction handler.

func NewRelicMetricsHandler added in v0.0.19

func NewRelicMetricsHandler(buildInfo config.BuildInfo) Handler

NewRelicMetricsHandler creates a new newrelic metrics handler.

type HandlerType added in v0.0.19

type HandlerType uint8

HandlerType is the handler type to use

const (
	// DataDog is the datadog driver.
	DataDog HandlerType = 0 // Datadog
	// NewRelic is the new relic driver.
	NewRelic HandlerType = iota // NewRelic
	// Null is a null data type handler.
	Null HandlerType = iota // Null
)

func (HandlerType) Lower added in v0.0.19

func (i HandlerType) Lower() string

Lower gets the lowercase version of the handler type. Useful for comparison in switch.

func (HandlerType) String added in v0.0.19

func (i HandlerType) String() string

Directories

Path Synopsis
Package newrelic provides custom wrpapers for newrelic.
Package newrelic provides custom wrpapers for newrelic.

Jump to

Keyboard shortcuts

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