Documentation ¶
Overview ¶
Package metrics implements a metrics dashboard with either datadog or prometheus (coming soon)
Index ¶
- Constants
- Variables
- func EndSpan(span trace.Span)
- func EndSpanWithErr(span trace.Span, err error)
- func NewNoOpExporter() metric.Exporter
- func PyroscopeWrapTracerProvider(provider trace.TracerProvider, buildInfo config.BuildInfo, ...) trace.TracerProvider
- func RPCClient(ctx context.Context, metrics Handler, url string, client *http.Client, ...) (*rpc.Client, error)
- func Setup(ctx context.Context, buildInfo config.BuildInfo) error
- func StartPyroscope(info config.BuildInfo) *pyroscope.Profiler
- type Handler
- func Get() Handler
- func NewByType(ctx context.Context, buildInfo config.BuildInfo, ht HandlerType) (handler Handler, err error)
- func NewDatadogMetricsHandler(buildInfo config.BuildInfo) Handler
- func NewFromEnv(ctx context.Context, buildInfo config.BuildInfo) (handler Handler, err error)
- func NewJaegerHandler(buildInfo config.BuildInfo) Handler
- func NewNullHandler() Handler
- func NewOTLPMetricsHandler(buildInfo config.BuildInfo) Handler
- type HandlerType
- type Meter
- type MeterImpl
- type NullCounter
- type NullHistogram
- type NullMeterImpl
- type TestHandler
Constants ¶
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" // Contract is the metric name for the contract. Contract = "contract" // MessageExecuted is the metric name for the message executed. MessageExecuted = "message_executed" )
const DDProfileEnv = "DD_PROFILES"
DDProfileEnv is the data daog profile neviornment variable.
const HandlerEnv = "METRICS_HANDLER"
HandlerEnv is the driver to use for metrics.
Variables ¶
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 EndSpanWithErr ¶ added in v0.0.43
EndSpanWithErr ends a span and records an error if one is present.
func NewNoOpExporter ¶ added in v0.0.64
NewNoOpExporter creates a new no-op metric exporter.
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.
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 // Meter returns an otel meter provider Meter() Meter }
Handler collects metrics.
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
NewDatadogMetricsHandler creates a new datadog metrics handler.
func NewFromEnv ¶ added in v0.0.19
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
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. TODO: this should extend the baseHandler, but we need to figure out how to do that with the jaeger exporter.
func NewNullHandler ¶ added in v0.0.19
func NewNullHandler() Handler
NewNullHandler creates a new null transaction handler.
func NewOTLPMetricsHandler ¶ added in v0.0.60
NewOTLPMetricsHandler 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 // OTLP is the new relic driver.t. OTLP // OTLP // 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 Meter ¶ added in v0.0.63
type Meter interface { // NewCounter creates a new meter counter instrument. NewCounter(meterName string, counterName string, desc string, units string) (metric.Int64Counter, error) // NewHistogram creates a new meter histogram instrument. NewHistogram(meterName string, histName string, desc string, units string) (metric.Int64Histogram, error) }
Meter is an interface for counter and histogram.
type MeterImpl ¶ added in v0.0.63
type MeterImpl struct {
// contains filtered or unexported fields
}
MeterImpl is an implementation of the MeterProvider interface.
func NewOtelMeter ¶ added in v0.0.63
func NewOtelMeter(serviceName string, interval time.Duration, exporter sdkmetric.Exporter) (*MeterImpl, error)
NewOtelMeter creates a new meter provider.
func (*MeterImpl) NewCounter ¶ added in v0.0.63
func (m *MeterImpl) NewCounter(meterName string, counterName string, desc string, units string) (metric.Int64Counter, error)
NewCounter creates a new meter counter instrument. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#counter
func (*MeterImpl) NewHistogram ¶ added in v0.0.63
func (m *MeterImpl) NewHistogram(meterName string, histName string, desc string, units string) (metric.Int64Histogram, error)
NewHistogram creates a new meter histogram instrument. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#histogram
type NullCounter ¶ added in v0.0.63
type NullCounter struct {
embedded.Int64Counter
}
NullCounter is a no-op implementation of the metric.Int64Counter.
type NullHistogram ¶ added in v0.0.63
type NullHistogram struct {
embedded.Int64Histogram
}
NullHistogram is a no-op implementation of the metric.Int64Histogram.
func (*NullHistogram) Record ¶ added in v0.0.63
func (n *NullHistogram) Record(_ context.Context, _ int64, _ ...metric.RecordOption)
Record is a no-op implementation of RecordOption Record() function.
type NullMeterImpl ¶ added in v0.0.63
type NullMeterImpl struct{}
NullMeterImpl is a no-op implementation of the Meter interface.
func (*NullMeterImpl) NewCounter ¶ added in v0.0.63
func (m *NullMeterImpl) NewCounter(_ string, _ string, _ string, _ string) (metric.Int64Counter, error)
NewCounter creates a new meter counter instrument.
func (*NullMeterImpl) NewHistogram ¶ added in v0.0.63
func (m *NullMeterImpl) NewHistogram(_ string, _ string, _ string, _ string) (metric.Int64Histogram, error)
NewHistogram creates a new meter histogram instrument.
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.
Source Files ¶
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. |