monitoring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package monitoring contains thin wrappers around the monitoring libraries used.

Its goal is not to create a completely new metrics/trace abstraction but rather to minimize places where the underlying monitoring libraries are directly used to make it easy to replace them if needed with the help of the compiler. Packages that expose metrics should define those metrics in a metrics.go file which would be the only file in the package to import OpenCensus. The rest of the package would use our monitoring wrappers to record metrics.

Index

Constants

View Source
const (
	StatusCodeOK                 = 0
	StatusCodeCancelled          = 1
	StatusCodeUnknown            = 2
	StatusCodeInvalidArgument    = 3
	StatusCodeDeadlineExceeded   = 4
	StatusCodeNotFound           = 5
	StatusCodeAlreadyExists      = 6
	StatusCodePermissionDenied   = 7
	StatusCodeResourceExhausted  = 8
	StatusCodeFailedPrecondition = 9
	StatusCodeAborted            = 10
	StatusCodeOutOfRange         = 11
	StatusCodeUnimplemented      = 12
	StatusCodeInternal           = 13
	StatusCodeUnavailable        = 14
	StatusCodeDataLoss           = 15
	StatusCodeUnauthenticated    = 16
)

Status codes.

Variables

View Source
var (
	ErrorTag      = NewTag("indigo-node/keys/error")
	PeerIDTag     = NewTag("indigo-node/keys/peerid")
	ProtocolIDTag = NewTag("indigo-node/keys/protocolid")
)

Common tags that can be used by all apps.

View Source
var (
	DefaultLatencyDistribution = view.Distribution(0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)
)

Common distributions that can be used by all apps.

Functions

This section is empty.

Types

type Float64Metric

type Float64Metric struct {
	Measure *stats.Float64Measure
}

Float64Metric is a float metric that can be tagged and recorded.

func NewFloat64

func NewFloat64(m *stats.Float64Measure) *Float64Metric

NewFloat64 creates a new Float64 metrics.

func (Float64Metric) Record

func (m Float64Metric) Record(ctx context.Context, val float64)

Record a value for the receiver metric.

type Int64Metric

type Int64Metric struct {
	Measure *stats.Int64Measure
}

Int64Metric is an integer metric that can be tagged and recorded.

func NewInt64

func NewInt64(m *stats.Int64Measure) *Int64Metric

NewInt64 creates a new Int64 metrics.

func (Int64Metric) Record

func (m Int64Metric) Record(ctx context.Context, val int64)

Record a value for the receiver metric.

type Span

type Span struct {
	// contains filtered or unexported fields
}

Span represents a span of a trace. It wraps an OpenCensus span. It will also log to the configured libp2p logger.

func StartSpan

func StartSpan(ctx context.Context, service string, method string, opts ...SpanOption) (context.Context, *Span)

StartSpan starts a new span.

func (*Span) AddBoolAttribute

func (s *Span) AddBoolAttribute(name string, value bool)

AddBoolAttribute sets a boolean attribute in the span.

func (*Span) AddIntAttribute

func (s *Span) AddIntAttribute(name string, value int64)

AddIntAttribute sets an integer attribute in the span.

func (*Span) AddStringAttribute

func (s *Span) AddStringAttribute(name string, value string)

AddStringAttribute sets a string attribute in the span.

func (*Span) Annotate

func (s *Span) Annotate(ctx context.Context, name, message string)

Annotate adds a log message to a span.

func (*Span) End

func (s *Span) End()

End ends the span.

func (*Span) SetAddrs

func (s *Span) SetAddrs(addrs []multiaddr.Multiaddr)

SetAddrs sets span's addresses.

func (*Span) SetPeerID

func (s *Span) SetPeerID(peerID peer.ID)

SetPeerID sets the span's peer ID.

func (*Span) SetProtocolID

func (s *Span) SetProtocolID(pid protocol.ID)

SetProtocolID sets the span's protocol ID.

func (*Span) SetStatus

func (s *Span) SetStatus(status Status)

SetStatus sets the status of the span.

func (*Span) SetUnknownError

func (s *Span) SetUnknownError(err error)

SetUnknownError sets the span status with an unclassified error (unknown).

type SpanOption

type SpanOption func(context.Context, *Span) context.Context

SpanOption sets some initial settings for the span and context.

func SpanOptionPeerID

func SpanOptionPeerID(peerID peer.ID) SpanOption

SpanOptionPeerID sets the span's peer ID and tags the context for metrics.

func SpanOptionProtocolID

func SpanOptionProtocolID(pid protocol.ID) SpanOption

SpanOptionProtocolID sets the span's protocol ID and tags the context for metrics.

type Status

type Status struct {
	Code    int32
	Message string
}

Status is the status of a Span.

func NewStatus

func NewStatus(code int32, message string) Status

NewStatus creates a new status object.

type Tag

type Tag struct {
	OCTag tag.Key
}

Tag can be associated to metrics.

func NewTag

func NewTag(name string) Tag

NewTag creates a new tag with the given name.

type TaggedContext

type TaggedContext struct {
	// contains filtered or unexported fields
}

TaggedContext is a builder to add tags to a context.

func NewTaggedContext

func NewTaggedContext(ctx context.Context) *TaggedContext

NewTaggedContext adds the given tags to the context.

func (*TaggedContext) Build

func (c *TaggedContext) Build() context.Context

Build returns the tagged context or an error.

func (*TaggedContext) Tag

func (c *TaggedContext) Tag(t Tag, val string) *TaggedContext

Tag tags the context with the given value.

Jump to

Keyboard shortcuts

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