Documentation ¶
Index ¶
- Constants
- func GetDeviceID(destinationRegex *regexp.Regexp, destination string) (string, error)
- func GetEventBootTime(msg Event) (int64, error)
- func GetMetadataValue(key string, metadata map[string]string) (string, bool)
- func GetValidBirthDate(currTime func() time.Time, payload []byte) (time.Time, error)
- func GetWRPBootTime(msg wrp.Message) (int64, error)
- func Provide() fx.Option
- func ProvideEventMetrics() fx.Option
- type AuthAcquirerConfig
- type BootTimeParser
- type CircuitBreakerConfig
- type CodexClient
- type CodexConfig
- type Event
- type EventClient
- type Measures
- type MetadataParser
- type ParsersIn
- type RebootTimeParser
Constants ¶
const ( FirmwareLabel = "firmware" HardwareLabel = "hardware" ParserLabel = "parser_type" ReasonLabel = "reason" )
const (
MetadataKeyLabel = "metadata_key"
)
Variables ¶
This section is empty.
Functions ¶
func GetDeviceID ¶
GetDeviceID grabs the device id from a given destination string.
func GetEventBootTime ¶
GetEventBootTime grabs the boot-time from a Event's metadata.
func GetMetadataValue ¶ added in v0.2.3
Checks a map for a specific key, allowing for keys with or without forward-slash
func GetValidBirthDate ¶ added in v0.2.0
GetValidBirthDate attempts to get the birthdate from the payload. If it doesn't exist, the current time is returned. If the birthdate is too old or too far in the future, 0 is returned.
func GetWRPBootTime ¶
GetWRPBootTime grabs the boot-time from a wrp.Message's metadata.
func Provide ¶
Provide bundles everything needed for setting up all of the event objects for easier wiring into an uber fx application.
func ProvideEventMetrics ¶
ProvideEventMetrics builds the event-related metrics and makes them available to the container.
Types ¶
type AuthAcquirerConfig ¶
type AuthAcquirerConfig struct { JWT acquire.RemoteBearerTokenAcquirerOptions Basic string }
type BootTimeParser ¶
type BootTimeParser struct { Measures Measures Logger log.Logger Client EventClient }
BootTimeParser takes online events and calculates the reboot time of a device by getting the last offline event from codex.
func (*BootTimeParser) Parse ¶
func (b *BootTimeParser) Parse(wrpWithTime queue.WrpWithTime) error
Parse calculates boot time of devices by querying codex for the latest offline events and performing
calculations. An analysis of codex events is only triggered by a device online event from caduceus. Steps to calculate boot time:
- Determine if message is online event.
- Get lastest Offline event from Codex where metadata field of /boot-time differs of online event.
- Subtract Online birthdate from steps 2 event Birthdate.
- Record Metric.
type CircuitBreakerConfig ¶
type CodexClient ¶
type CodexClient struct { Address string Auth acquire.Acquirer // contains filtered or unexported fields }
func (*CodexClient) GetEvents ¶
func (c *CodexClient) GetEvents(device string) []Event
GetEvents queries codex for events related to a device.
type CodexConfig ¶
type CodexConfig struct { Address string Auth AuthAcquirerConfig MaxRetryCount int CircuitBreaker CircuitBreakerConfig }
CodexConfig determines the auth and address for connecting to the codex cluster.
type Event ¶
type Event struct { MsgType int `json:"msg_type"` Source string `json:"source"` Dest string `json:"dest,omitempty"` TransactionUUID string `json:"transaction_uuid,omitempty"` ContentType string `json:"content_type,omitempty"` Metadata map[string]string `json:"metadata"` Payload string `json:"payload,omitempty"` BirthDate int64 `json:"birth_date"` PartnerIDs []string `json:"partner_ids,omitempty"` }
Event is the struct that codex query results will be unmarshalled into.
type EventClient ¶
type Measures ¶
type Measures struct { fx.In MetadataFields metrics.Counter `name:"metadata_fields"` BootTimeHistogram metrics.Histogram `name:"boot_time_duration"` RebootTimeHistogram metrics.Histogram `name:"reboot_to_manageable_duration"` UnparsableEventsCount metrics.Counter `name:"unparsable_events_count"` }
Measures tracks the various event-related metrics.
type MetadataParser ¶
type MetadataParser struct {
Measures Measures
}
MetadataParser parses messages coming in and counts the various metadata keys of each request.
func (MetadataParser) Parse ¶
func (m MetadataParser) Parse(wrpWithTime queue.WrpWithTime) error
Parse gathers metrics for each metadata key.
type RebootTimeParser ¶ added in v0.2.0
type RebootTimeParser struct { Measures Measures Logger log.Logger Client EventClient Label string }
RebootTimeParser takes fully-manageable events and calculates the reboot time of a device by getting the last reboot-pending event from codex.
func (*RebootTimeParser) Parse ¶ added in v0.2.0
func (b *RebootTimeParser) Parse(wrpWithTime queue.WrpWithTime) error
Parse calculates reboot time of devices by querying codex for the latest device events and performing calculations. An analysis of codex events is only triggered by a fully-manageable event from caduceus. Steps to calculate boot time: 1) Determine if message is fully-manageable event. 2) Get latest reboot-pending event from Codex where metadata field of /boot-time differs from the fully-manageable event. 3) Subtract fully-manageable's birthdate from step 2's event birthdate. 4) Record Metric.