Documentation ¶
Overview ¶
Package reporting provides increased observability of the state of MongoDB-backed amboy queues.
Index ¶
- Constants
- type CounterFilter
- type DBQueueReporterOptions
- type ErrorFilter
- type JobCounters
- type JobErrorsForType
- type JobErrorsReport
- type JobReportIDs
- type JobRuntimeReport
- type JobRuntimes
- type JobStatusReport
- type Reporter
- func MakeDBQueueState(ctx context.Context, opts DBQueueReporterOptions, client *mongo.Client) (Reporter, error)
- func MakeLegacyDBQueueState(name string, opts queue.MongoDBOptions, session *mgo.Session) (Reporter, error)
- func NewDBQueueState(ctx context.Context, opts DBQueueReporterOptions) (Reporter, error)
- func NewLegacyDBQueueState(name string, opts queue.MongoDBOptions) (Reporter, error)
- func NewQueueReporter(q amboy.Queue) Reporter
- type RuntimeFilter
Constants ¶
const ( InProgress CounterFilter = "in-progress" Pending = "pending" Stale = "stale" )
nolint
const ( Duration RuntimeFilter = "completed" Latency = "latency" Running = "running" )
nolint
const ( UniqueErrors ErrorFilter = "unique-errors" AllErrors = "all-errors" StatsOnly = "stats-only" )
nolint
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CounterFilter ¶
type CounterFilter string
CounterFilter defines a number of dimensions with which to filter current jobs in a queue.
func (CounterFilter) Validate ¶
func (t CounterFilter) Validate() error
Validate returns an error if a filter value is not valid.
type DBQueueReporterOptions ¶
type DBQueueReporterOptions struct { Name string Group string SingleGroup bool ByGroups bool Options queue.MongoDBOptions }
DBQueueReporterOptions describes the arguments to the operations to construct queue reporters, and accommodates both group-backed queues and conventional queues.
func (*DBQueueReporterOptions) Validate ¶
func (o *DBQueueReporterOptions) Validate() error
Validate checks the state of the reporter configuration, preventing logically invalid options.
type ErrorFilter ¶
type ErrorFilter string
ErrorFilter defines post-processing on errors as returned to users in error queries.
func (ErrorFilter) Validate ¶
func (t ErrorFilter) Validate() error
Validate returns an error if a filter value is not valid.
type JobCounters ¶
type JobCounters struct { ID string `bson:"_id" json:"type" yaml:"type"` Count int `bson:"count" json:"count" yaml:"count"` Group string `bson:"group,omitempty" json:"group,omitempty" yaml:"group,omitempty"` }
JobCounters holds data for counts of jobs by type.
type JobErrorsForType ¶
type JobErrorsForType struct { ID string `bson:"_id" json:"type" yaml:"type"` Count int `bson:"count" json:"count" yaml:"count"` Total int `bson:"total" json:"total" yaml:"total"` Average float64 `bson:"average" json:"average" yaml:"average"` Errors []string `bson:"errors,omitempty" json:"errors,omitempty" yaml:"errors,omitempty"` Group string `bson:"group,omitempty" json:"group,omitempty" yaml:"group,omitempty"` }
JobErrorsForType holds data about the errors for a specific type of jobs.
type JobErrorsReport ¶
type JobErrorsReport struct { Period time.Duration `bson:"period" json:"period" yaml:"period"` FilteredByType bool `bson:"filtered" json:"filtered" yaml:"filtered"` Data []JobErrorsForType `bson:"data" json:"data" yaml:"data"` }
JobErrorsReport contains data for all job errors, by job type, for a specific period.
type JobReportIDs ¶
type JobReportIDs struct { Type string `bson:"_id" json:"type" yaml:"type"` Filter string `bson:"filter" json:"filter" yaml:"filter"` IDs []string `bson:"jobs" json:"jobs" yaml:"jobs"` Group string `bson:"group,omitempty" json:"group,omitempty" yaml:"group,omitempty"` }
JobReportIDs contains the IDs of all jobs of a specific type.
type JobRuntimeReport ¶
type JobRuntimeReport struct { Filter string `bson:"filter" json:"filter" yaml:"filter"` Period time.Duration `bson:"period" json:"period" yaml:"period"` Stats []JobRuntimes `bson:"data" json:"data" yaml:"data"` }
JobRuntimeReport contains data for the runtime of jobs, by type, that have run a specified period.
type JobRuntimes ¶
type JobRuntimes struct { ID string `bson:"_id" json:"type" yaml:"type"` Duration time.Duration `bson:"duration" json:"duration" yaml:"duration"` Group string `bson:"group,omitempty" json:"group,omitempty" yaml:"group,omitempty"` }
JobRuntimes holds data for runtimes of jobs by type.
type JobStatusReport ¶
type JobStatusReport struct { Filter string `bson:"filter" json:"filter" yaml:"filter"` Stats []JobCounters `bson:"data" json:"data" yaml:"data"` }
JobStatusReport contains data for the numbers of jobs that exist for a specified type.
type Reporter ¶
type Reporter interface { JobStatus(context.Context, CounterFilter) (*JobStatusReport, error) RecentTiming(context.Context, time.Duration, RuntimeFilter) (*JobRuntimeReport, error) JobIDsByState(context.Context, string, CounterFilter) (*JobReportIDs, error) RecentErrors(context.Context, time.Duration, ErrorFilter) (*JobErrorsReport, error) RecentJobErrors(context.Context, string, time.Duration, ErrorFilter) (*JobErrorsReport, error) }
Reporter is an interface that describes queue introspection tools that make it possible to get more details about the running jobs in an amboy queue.
func MakeDBQueueState ¶
func MakeDBQueueState(ctx context.Context, opts DBQueueReporterOptions, client *mongo.Client) (Reporter, error)
MakeDBQueueState make it possible to produce a queue reporter with an existing database Connection. This operations runs the "ping" command and will return an error if there is no session or no active server.
func MakeLegacyDBQueueState ¶
func MakeLegacyDBQueueState(name string, opts queue.MongoDBOptions, session *mgo.Session) (Reporter, error)
MakeLegacyDBQueueState make it possible to produce a queue reporter with an existing database Connection. This operations runs the "ping" command and will return an error if there is no session or no active server.
This implementation uses a legacy MGO driver connection to the database.
func NewDBQueueState ¶
func NewDBQueueState(ctx context.Context, opts DBQueueReporterOptions) (Reporter, error)
NewDBQueueState produces a queue Reporter for (remote) queues that persist jobs in MongoDB. This implementation does not interact with a queue directly, and reports by interacting with the database directly.
func NewLegacyDBQueueState ¶
func NewLegacyDBQueueState(name string, opts queue.MongoDBOptions) (Reporter, error)
NewLegacyDBQueueState produces a queue Reporter for (remote) queues that persist jobs in MongoDB. This implementation does not interact with a queue directly, and reports by interacting with the database directly.
This implementation creates a connection using the legacy MGO driver.
func NewQueueReporter ¶
NewQueueReporter returns a queue state reporter that provides the Reporter supported by calling the output of amboy.Queue.Results() and amboy.Queue.JobStats(). iterating over jobs directly. Use this to introspect in-memory queue implementations more generically.
The reporting algorithms may impact performance of jobs, as queues may require some locking to their Jobs function. Additionally, the speed of these operations will necessarily degrade with the number of jobs. Do pass contexts with timeouts to in these cases.
type RuntimeFilter ¶
type RuntimeFilter string
RuntimeFilter provides ways to filter the timing data returned by the reporting interface.
func (RuntimeFilter) Validate ¶
func (t RuntimeFilter) Validate() error
Validate returns an error if a filter value is not valid.