Documentation ¶
Index ¶
- Constants
- Variables
- func Configure(config *Config, serviceName string) (http.Handler, error)
- func LogEntry() *log.Entry
- func NewFossilizerAdapter(f fossilizer.Adapter, name string) fossilizer.Adapter
- func RegisterFlags()
- func SetSpanStatus(span *apm.Span, err error)
- func SetSpanStatusAndEnd(span *apm.Span, err error)
- func SetVersion(v, c string)
- func SpanLogEntry(span *apm.Span) *log.Entry
- func StartSpanIncomingRequest(ctx context.Context, name string) (*apm.Span, context.Context)
- func StartSpanOutgoingRequest(ctx context.Context, name string) (*apm.Span, context.Context)
- func StartSpanProcessing(ctx context.Context, name string) (*apm.Span, context.Context)
- func TxLogEntry(ctx context.Context) *log.Entry
- func WrapKeyValueStore(s store.KeyValueStore, name string) store.KeyValueStore
- func WrapStore(s store.Adapter, name string) store.Adapter
- type Config
- type FossilizerAdapter
- type KeyValueStoreAdapter
- type StoreAdapter
- func (a *StoreAdapter) AddEvidence(ctx context.Context, linkHash chainscript.LinkHash, ...) (err error)
- func (a *StoreAdapter) AddStoreEventChannel(c chan *store.Event)
- func (a *StoreAdapter) CreateLink(ctx context.Context, link *chainscript.Link) (lh chainscript.LinkHash, err error)
- func (a *StoreAdapter) FindSegments(ctx context.Context, filter *store.SegmentFilter) (ss *types.PaginatedSegments, err error)
- func (a *StoreAdapter) GetEvidences(ctx context.Context, linkHash chainscript.LinkHash) (e types.EvidenceSlice, err error)
- func (a *StoreAdapter) GetInfo(ctx context.Context) (res interface{}, err error)
- func (a *StoreAdapter) GetMapIDs(ctx context.Context, filter *store.MapFilter) (mids []string, err error)
- func (a *StoreAdapter) GetSegment(ctx context.Context, linkHash chainscript.LinkHash) (s *chainscript.Segment, err error)
- func (a *StoreAdapter) NewBatch(ctx context.Context) (b store.Batch, err error)
Constants ¶
const ( PrometheusExporter = "prometheus" ElasticExporter = "elastic" )
Available exporters.
const ( Stratumn = "stratumn" ErrorLabel = "error" ErrorCodeLabel = "error_code" ErrorComponentLabel = "error_component" )
Metrics and labels available to all packages.
const ( SpanTypeIncomingRequest = "app.request.incoming" SpanTypeOutgoingRequest = "app.request.outgoing" SpanTypeProcessing = "app.processing" )
Span types.
Variables ¶
var (
DefaultLatencyBuckets = []float64{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}
)
Default buckets used by histograms.
var (
ErrInvalidExporter = errors.New("exporter should be 'prometheus' or 'elastic'")
)
Errors used by the configuration module.
Functions ¶
func Configure ¶
Configure configures metrics and trace monitoring. If metrics need to be exposed on an http route ('/metrics'), this function returns an http.Handler. It returns nil otherwise.
func NewFossilizerAdapter ¶
func NewFossilizerAdapter(f fossilizer.Adapter, name string) fossilizer.Adapter
NewFossilizerAdapter decorates an existing fossilizer.
func RegisterFlags ¶
func RegisterFlags()
RegisterFlags registers the command-line monitoring flags.
func SetSpanStatus ¶ added in v0.3.1
SetSpanStatus sets the status of the span depending on the error.
func SetSpanStatusAndEnd ¶
SetSpanStatusAndEnd sets the status of the span depending on the error and ends it. You should usually call:
defer func() { SetSpanStatusAndEnd(span, err) }()
func SetVersion ¶ added in v0.3.1
func SetVersion(v, c string)
SetVersion sets the current code's version and commit.
func SpanLogEntry ¶ added in v0.3.1
SpanLogEntry creates a new log entry with the transaction ID set. This makes it easier to correlate transactions/spans with logs.
func StartSpanIncomingRequest ¶ added in v0.3.1
StartSpanIncomingRequest starts a new span for an incoming request and fills some common flags.
func StartSpanOutgoingRequest ¶ added in v0.3.1
StartSpanOutgoingRequest starts a new span for an outgoing request and fills some common flags.
func StartSpanProcessing ¶ added in v0.3.1
StartSpanProcessing starts a new span for an internal processing task and fills some common flags.
func TxLogEntry ¶ added in v0.3.1
TxLogEntry creates a new log entry with the transaction ID set. This makes it easier to correlate transactions/spans with logs.
func WrapKeyValueStore ¶ added in v0.3.1
func WrapKeyValueStore(s store.KeyValueStore, name string) store.KeyValueStore
WrapKeyValueStore wraps an existing key value store adapter to add monitoring.
Types ¶
type Config ¶
type Config struct { // Set to true to monitor Stratumn components. Monitor bool // Port used to expose metrics. MetricsPort int // Exporter is the name of the metrics and traces exporter. Exporter string }
Config contains options for monitoring.
func ConfigurationFromFlags ¶
func ConfigurationFromFlags() *Config
ConfigurationFromFlags builds configuration from user-provided command-line flags.
type FossilizerAdapter ¶
type FossilizerAdapter struct {
// contains filtered or unexported fields
}
FossilizerAdapter is a decorator for the Fossilizer interface. It wraps a real Fossilizer implementation and adds instrumentation.
func (*FossilizerAdapter) AddFossilizerEventChan ¶
func (a *FossilizerAdapter) AddFossilizerEventChan(c chan *fossilizer.Event)
AddFossilizerEventChan instruments the call and delegates to the underlying fossilizer.
type KeyValueStoreAdapter ¶
type KeyValueStoreAdapter struct {
// contains filtered or unexported fields
}
KeyValueStoreAdapter is a decorator for the store.KeyValueStore interface. It wraps a real store.KeyValueStore implementation and adds instrumentation.
func (*KeyValueStoreAdapter) DeleteValue ¶
DeleteValue instruments the call and delegates to the underlying store.
type StoreAdapter ¶
type StoreAdapter struct {
// contains filtered or unexported fields
}
StoreAdapter is a decorator for the store.Adapter interface. It wraps a real store.Adapter implementation and adds instrumentation.
func (*StoreAdapter) AddEvidence ¶
func (a *StoreAdapter) AddEvidence(ctx context.Context, linkHash chainscript.LinkHash, evidence *chainscript.Evidence) (err error)
AddEvidence instruments the call and delegates to the underlying store.
func (*StoreAdapter) AddStoreEventChannel ¶
func (a *StoreAdapter) AddStoreEventChannel(c chan *store.Event)
AddStoreEventChannel instruments the call and delegates to the underlying store.
func (*StoreAdapter) CreateLink ¶
func (a *StoreAdapter) CreateLink(ctx context.Context, link *chainscript.Link) (lh chainscript.LinkHash, err error)
CreateLink instruments the call and delegates to the underlying store.
func (*StoreAdapter) FindSegments ¶
func (a *StoreAdapter) FindSegments(ctx context.Context, filter *store.SegmentFilter) (ss *types.PaginatedSegments, err error)
FindSegments instruments the call and delegates to the underlying store.
func (*StoreAdapter) GetEvidences ¶
func (a *StoreAdapter) GetEvidences(ctx context.Context, linkHash chainscript.LinkHash) (e types.EvidenceSlice, err error)
GetEvidences instruments the call and delegates to the underlying store.
func (*StoreAdapter) GetInfo ¶
func (a *StoreAdapter) GetInfo(ctx context.Context) (res interface{}, err error)
GetInfo instruments the call and delegates to the underlying store.
func (*StoreAdapter) GetMapIDs ¶
func (a *StoreAdapter) GetMapIDs(ctx context.Context, filter *store.MapFilter) (mids []string, err error)
GetMapIDs instruments the call and delegates to the underlying store.
func (*StoreAdapter) GetSegment ¶
func (a *StoreAdapter) GetSegment(ctx context.Context, linkHash chainscript.LinkHash) (s *chainscript.Segment, err error)
GetSegment instruments the call and delegates to the underlying store.