Documentation
¶
Overview ¶
Package evtlog provides a client/service which allows asynchronously reporting events to the '/_event' endpoint provided by 'ns_server'.
Index ¶
Constants ¶
const ( // MaxEncodedLength is the maximum size of the JSON encoded event. MaxEncodedLength = 3 * 1024 // MaxBufferedEventsPerDispatcher is the default number of events (and minimum) number of events that can be buffered // per-goroutine. MaxBufferedEventsPerDispatcher = 8 )
const ( // EndpointPostEvent is the endpoint used to 'POST' events. EndpointPostEvent cbrest.Endpoint = "/_event" )
Variables ¶
var ErrTooLarge = errors.New("payload too large")
ErrTooLarge returned if the encoded event payload is larger than 3KiB.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a wrapper around the 'cbrest' client which implements the required methods to log events.
func NewClient ¶
func NewClient(options ServiceOptions) (*Client, error)
NewClient creates a new client using the given options, the client may communicate using basic/cert auth depending on the auth provider/tls config provided.
type Component ¶
type Component string
Component represents to component which is reporting this event, for a complete list of supported components see MB-47035 and its parent.
type Event ¶
type Event struct {
// Required attributes which, if not supplied will result in an error.
Component Component `json:"component"`
Severity Severity `json:"severity"`
EventID EventID `json:"event_id"`
Description string `json:"description"`
// Optional attributes which may/or may not be supplied; the general recommendation is to include some additional
// useful information which describes the event.
ExtraAttributes any `json:"extra_attributes"`
SubComponent string `json:"sub_component"`
}
Event represents an event, and is the structure which will be used when reporting events using a 'Service'.
func (Event) MarshalJSON ¶
MarshalJSON implements the 'json.Marshaller' interface, and fills in any required automatically generated fields.
type EventID ¶
type EventID uint
EventID is the unique identifier of the event type, currently each service is apportioned 1024 event ids.
NOTE: See MB-47035 and its parent for more information about which services are supplied which ids.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service exposes an interface to report events to the local 'ns_server' instance.
func NewService ¶
func NewService(options ServiceOptions) (*Service, error)
NewService creates a new service using the given options.
type ServiceOptions ¶
type ServiceOptions struct {
ManagementPort uint16
Provider aprov.Provider
TLSConfig *tls.Config
// ReqResLogLevel is the level at which HTTP requests/responses will be logged; this directly maps to the 'cbrest'
// client value.
ReqResLogLevel log.Level
// The number of goroutines to create for reporting events.
Dispatchers int
// MaxBufferedEventsPerDispatcher directly maps to the 'hofp.BufferMultiplier' value, and dictates the number of events
// that can be buffered per-goroutine.
MaxBufferedEventsPerDispatcher int
// Logger is the passed Logger struct that implements the Log method for logger the user wants to use.
Logger log.Logger
}
ServiceOptions encapsulates the options available when creating a new event log service.
type Severity ¶
type Severity string
Severity represents the severity of an event.
const ( // SeverityInfo is the 'info' level, describing something that occurs during normal execution and is therefore // expected. SeverityInfo Severity = "info" // SeverityWarn is the 'warn' level, describing something that's normal (or perhaps rare/unexpected). SeverityWarn Severity = "warn" // SeverityError is the 'error' level, describing error scenarios where something has failed/occurred that shouldn't // happen during normal execution. SeverityError Severity = "error" // SeverityFatal is the 'fatal' level, describing an error case which is unrecoverable. SeverityFatal Severity = "fatal" )