Documentation ¶
Index ¶
- Variables
- func CheckFilenameMD5(data []byte, path string) (bool, error)
- func MD5FileNamer(bytes []byte) string
- func MD5Str(bytes []byte) string
- func MD5StrUrl(bytes []byte) string
- func NewContextForEvent(ctx context.Context, evt *Event) context.Context
- type Collector
- type Counter
- type Emitter
- type Event
- type EventMetric
- type FileBackedProc
- type FileEmitter
- type Flusher
- type GrpcEmitter
- type GrpcEventFlusher
- type IOFlusher
- type NullEmitter
- type Timer
- type WriterEmitter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEventsDataDir occurs when events are trying to be flushed, but the events data directory // does not yet exist ErrEventsDataDir = errors.New("unable to flush, events data directory does not exist") // ErrFileLocked occurs if the current file or dir is locked for processing ErrFileLocked = errors.New("file is currently locked") )
var EventNowFunc = time.Now
EventNowFunc function is used to get the current time and can be overridden for testing.
var GlobalCollector = NewCollector()
GlobalCollector is an instance of a collector where all events should be sent via the CloseEventAndAdd function
Functions ¶
func CheckFilenameMD5 ¶
CheckFilenameMD5 is the fileNamingFunc used when instantiating a FileBackedProc
func MD5FileNamer ¶
MD5FileNamer names files after the base64 url encoding of the md5 hash of the contents of the file
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector collects and stores Events later to be sent to an Emitter.
func NewCollector ¶
func NewCollector() *Collector
NewCollector creates a new instance of a collector
func (*Collector) Close ¶
func (c *Collector) Close() []*eventsapi.ClientEvent
Close waits for any remaining events to finish collection and then returns a slice of ClientEvents to be passed to an emitter.
func (*Collector) CloseEventAndAdd ¶
CloseEventAndAdd closes the supplied event and adds it to the collection of events. This method is thread safe.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a metric for counting
func NewCounter ¶
NewCounter creates a new counter
func (*Counter) AsClientEventMetric ¶
func (c *Counter) AsClientEventMetric() *eventsapi.ClientEventMetric
AsClientEventMetrics gets the eventsapi.ClientEventMetric encoding of a metric
type Emitter ¶
type Emitter interface { // LogEvents takes a batch of events and processes them LogEvents(version string, evts []*eventsapi.ClientEvent) error }
Emitter is an interface used for processing a batch of events
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is an event to be added to a collector and logged
func GetEventFromContext ¶
GetEventFromContext retrieves the event from the context if one exists.
func NewEvent ¶
func NewEvent(ceType eventsapi.ClientEventType) *Event
NewEvent creates an Event of a given type. The event creation time is recorded as the start time for the event. When the event is passed to a collector's CloseEventAndAdd method the end time of the event is recorded
func (*Event) AddMetric ¶
func (evt *Event) AddMetric(em EventMetric)
AddMetric adds a metric to the event. This method is thread safe.
func (*Event) SetAttribute ¶
func (evt *Event) SetAttribute(attID eventsapi.AttributeID, attVal string)
SetAttribute adds an attribute to the event. This method is thread safe
type EventMetric ¶
type EventMetric interface { // AsClientEventMetrics gets the eventsapi.ClientEventMetric encoding of a metric AsClientEventMetric() *eventsapi.ClientEventMetric }
EventMetric is an interface for getting the eventsapi.ClientEventMetric encoding of a metric
type FileBackedProc ¶
type FileBackedProc struct { CheckingFunc fileCheckingFunc LockPath string // contains filtered or unexported fields }
FileBackedProc writes events requests to files in an events data dir
func NewFileBackedProc ¶
func NewFileBackedProc(fs filesys.Filesys, userHomeDir string, doltDir string, nf fileNamingFunc, cf fileCheckingFunc) *FileBackedProc
NewFileBackedProc creates a new FileBackedProc
func (*FileBackedProc) EventsDirExists ¶
func (fbp *FileBackedProc) EventsDirExists() bool
EventsDirExists returns true iff the events data dir exists
func (*FileBackedProc) GetEventsDirPath ¶
func (fbp *FileBackedProc) GetEventsDirPath() string
GetEventsDirPath returns the path to the events data dir
func (*FileBackedProc) GetFileSys ¶
func (fbp *FileBackedProc) GetFileSys() filesys.Filesys
GetFileSys returns the current filesys being used
func (*FileBackedProc) WriteEvents ¶
func (fbp *FileBackedProc) WriteEvents(version string, evts []*eventsapi.ClientEvent) error
WriteEvents writes events requests to the events data dir
type FileEmitter ¶
type FileEmitter struct {
// contains filtered or unexported fields
}
FileEmitter saves event requests to files
func NewFileEmitter ¶
func NewFileEmitter(userHomeDir string, doltDir string) *FileEmitter
NewFileEmitter creates a new file emitter
func (*FileEmitter) LogEvents ¶
func (fe *FileEmitter) LogEvents(version string, evts []*eventsapi.ClientEvent) error
LogEvents implements the Emitter interface and writes events requests to files
type GrpcEmitter ¶
type GrpcEmitter struct {
// contains filtered or unexported fields
}
GrpcEmitter sends events to a GRPC service implementing the eventsapi
func NewGrpcEmitter ¶
func NewGrpcEmitter(conn *grpc.ClientConn) *GrpcEmitter
NewGrpcEmitter creates a new GrpcEmitter
func (*GrpcEmitter) LogEvents ¶
func (em *GrpcEmitter) LogEvents(version string, evts []*eventsapi.ClientEvent) error
func (*GrpcEmitter) SendLogEventsRequest ¶
func (em *GrpcEmitter) SendLogEventsRequest(ctx context.Context, req *eventsapi.LogEventsRequest) error
SendLogEventsRequest sends a request using the grpc client
type GrpcEventFlusher ¶
type GrpcEventFlusher struct {
// contains filtered or unexported fields
}
GrpcEventFlusher parses dolt event logs sends the events to the events server
func NewGrpcEventFlusher ¶
func NewGrpcEventFlusher(fs filesys.Filesys, userHomeDir string, doltDir string, grpcEmitter *GrpcEmitter) *GrpcEventFlusher
NewGrpcEventFlusher creates a new GrpcEventFlusher
type IOFlusher ¶
type IOFlusher struct {
// contains filtered or unexported fields
}
IOFlusher parses event files and writes them to stdout
func NewIOFlusher ¶
NewIOFlusher creates a new IOFlusher
type NullEmitter ¶
type NullEmitter struct{}
NullEmitter is an emitter that drops events
func (NullEmitter) LogEvents ¶
func (ne NullEmitter) LogEvents(version string, evts []*eventsapi.ClientEvent) error
LogEvents takes a batch of events and processes them. In this case it just drops them
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer a timer is used to time how long something ran for.
func (*Timer) AsClientEventMetric ¶
func (t *Timer) AsClientEventMetric() *eventsapi.ClientEventMetric
AsClientEventMetrics gets the eventsapi.ClientEventMetric encoding of a metric
type WriterEmitter ¶
WriterEmitter is an emitter that writes the text encoding of the events to it's writer
func (WriterEmitter) LogEvents ¶
func (we WriterEmitter) LogEvents(version string, evts []*eventsapi.ClientEvent) error
LogEvents takes a batch of events and processes them. In this case the text encoding of the events is written to the writer