metrics

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: MIT Imports: 41 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

Jaeger

Pass in the JAEGER_ENDPOINT enviornment variable

Pyroscope

Pass in the PYROSCOPE_ENDPOINT environment variable

Documentation

Overview

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

Index

Constants

View Source
const (
	// ChainID is the metric name for the chain ID.
	ChainID = "chain_id"
	// ContractAddress is the metric name for the contract address.
	ContractAddress = "contract_address"
	// Origin is the metric name for the origin chain ID.
	Origin = "origin_chain_id"
	// Destination is the metric name for the destination chain ID.
	Destination = "destination_chain_id"
	// Nonce is the metric name for the nonce.
	Nonce = "nonce"
	// TxHash is the metric name for the transaction hash.
	TxHash = "tx_hash"
	// Page is the metric name for the page.
	Page = "page"
)
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 EndSpan added in v0.0.43

func EndSpan(span trace.Span)

EndSpan ends a span.

func EndSpanWithErr added in v0.0.43

func EndSpanWithErr(span trace.Span, err error)

EndSpanWithErr ends a span and records an error if one is present.

func PyroscopeWrapTracerProvider added in v0.0.43

func PyroscopeWrapTracerProvider(provider trace.TracerProvider, buildInfo config.BuildInfo, extraOpts ...otelpyroscope.Option) trace.TracerProvider

PyroscopeWrapTracerProvider wraps the tracer provider with pyroscope. The traceProvider is not affected if the pyroscope endpoint is not set.

func RPCClient added in v0.0.43

func RPCClient(ctx context.Context, metrics Handler, url string, client *http.Client, opts ...otelhttp.Option) (*rpc.Client, error)

RPCClient is a wrapper around rpc.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.

func StartPyroscope added in v0.0.43

func StartPyroscope(info config.BuildInfo) *pyroscope.Profiler

StartPyroscope starts the pyroscope profiler. this will not run if the pyroscope endpoint is not set.

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, opts ...otelhttp.Option)
	// AddGormCallbacks adds gorm callbacks for tracing.
	AddGormCallbacks(db *gorm.DB)
	// GetTracerProvider returns the tracer provider.
	GetTracerProvider() trace.TracerProvider
	// Tracer returns the tracer provider.
	Tracer() trace.Tracer
	// Propagator returns the propagator.
	Propagator() propagation.TextMapPropagator
	// Type returns the handler type.
	Type() HandlerType
}

Handler collects metrics.

func Get added in v0.0.19

func Get() Handler

Get gets the global handler.

func NewByType added in v0.0.43

func NewByType(ctx context.Context, buildInfo config.BuildInfo, ht HandlerType) (handler Handler, err error)

NewByType sets up a metrics handler by type.

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 NewJaegerHandler added in v0.0.43

func NewJaegerHandler(buildInfo config.BuildInfo) Handler

NewJaegerHandler creates a new jaeger handler for handling jaeger traces. the JAEGER_ENDPOINT environment variable must be set for this to work. Note: currently, this is only suitable for local runs, because of default options we've put in place This can be fixed in a future version through an option builder.

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 = iota + 1 // Datadog
	// NewRelic is the new relic driver.t.
	NewRelic // NewRelic
	// Jaeger is the jaeger driver.
	Jaeger // Jaeger
	// Null is a null data type handler.
	Null // 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

type TestHandler added in v0.0.43

type TestHandler interface {
	Handler
	// GetSpansByName returns all spans with the given name.
	GetSpansByName(name string) (spans []tracetest.SpanStub)
}

TestHandler is a handler that can be used for testing traces.

func NewTestTracer added in v0.0.43

func NewTestTracer(ctx context.Context, tb testing.TB) TestHandler

NewTestTracer returns a new test tracer.

Directories

Path Synopsis
Package internal contains internal constants for metrics package this is done in a separate package to avoid circular dependencies
Package internal contains internal constants for metrics package this is done in a separate package to avoid circular dependencies
Package localmetrics provides a local server for metrics.
Package localmetrics provides a local server for metrics.
Package newrelic provides custom wrpapers for newrelic.
Package newrelic provides custom wrpapers for newrelic.
Package pyroscope implements pyroscope.io client.
Package pyroscope implements pyroscope.io client.

Jump to

Keyboard shortcuts

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