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
- Variables
- type Float64Metric
- type Int64Metric
- type Span
- func (s *Span) AddBoolAttribute(name string, value bool)
- func (s *Span) AddIntAttribute(name string, value int64)
- func (s *Span) AddStringAttribute(name string, value string)
- func (s *Span) Annotate(ctx context.Context, name, message string)
- func (s *Span) End()
- func (s *Span) SetAddrs(addrs []multiaddr.Multiaddr)
- func (s *Span) SetPeerID(peerID peer.ID)
- func (s *Span) SetProtocolID(pid protocol.ID)
- func (s *Span) SetStatus(status Status)
- func (s *Span) SetUnknownError(err error)
- type SpanOption
- type Status
- type Tag
- type TaggedContext
Constants ¶
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 StatusCodeDataLoss = 15 StatusCodeUnauthenticated = 16 )
Status codes.
Variables ¶
var ( ErrorTag = NewTag("stratumn-node/keys/error") PeerIDTag = NewTag("stratumn-node/keys/peerid") ProtocolIDTag = NewTag("stratumn-node/keys/protocolid") )
Common tags that can be used by all apps.
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.
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.
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 ¶
AddBoolAttribute sets a boolean attribute in the span.
func (*Span) AddIntAttribute ¶
AddIntAttribute sets an integer attribute in the span.
func (*Span) AddStringAttribute ¶
AddStringAttribute sets a string attribute in 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) SetUnknownError ¶
SetUnknownError sets the span status with an unclassified error (unknown).
type SpanOption ¶
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 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.