amboy: Index | Files

package reporting

import ""

Package reporting provides increased observability of the state of MongoDB-backed amboy queues.


Package Files

doc.go mongodb.go output.go queue.go reporting.go


const (
    InProgress CounterFilter = "in-progress"
    Pending                  = "pending"
    Stale                    = "stale"


const (
    Duration RuntimeFilter = "completed"
    Latency                = "latency"
    Running                = "running"


const (
    UniqueErrors ErrorFilter = "unique-errors"
    AllErrors                = "all-errors"
    StatsOnly                = "stats-only"


type CounterFilter Uses

type CounterFilter string

CounterFilter defines a number of dimensions with which to filter current jobs in a queue.

func (CounterFilter) Validate Uses

func (t CounterFilter) Validate() error

Validate returns an error if a filter value is not valid.

type ErrorFilter Uses

type ErrorFilter string

ErrorFilter defines post-processing on errors as returned to users in error queries.

func (ErrorFilter) Validate Uses

func (t ErrorFilter) Validate() error

Validate returns an error if a filter value is not valid.

type JobCounters Uses

type JobCounters struct {
    ID    string `bson:"_id" json:"type" yaml:"type"`
    Count int    `bson:"count" json:"count" yaml:"count"`

JobCounters holds data for counts of jobs by type.

type JobErrorsForType Uses

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"`

JobErrorsForType holds data about the errors for a specific type of jobs.

type JobErrorsReport Uses

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 Uses

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"`

JobReportIDs contains the IDs of all jobs of a specific type.

type JobRuntimeReport Uses

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 Uses

type JobRuntimes struct {
    ID       string        `bson:"_id" json:"type" yaml:"type"`
    Duration time.Duration `bson:"duration" json:"duration" yaml:"duration"`

JobRuntimes holds data for runtimes of jobs by type.

type JobStatusReport Uses

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 Uses

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 Uses

func MakeDBQueueState(name string, opts queue.MongoDBOptions, session *mgo.Session) (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 NewDBQueueState Uses

func NewDBQueueState(name string, opts queue.MongoDBOptions) (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.

Timeouts associated contexts passed to the reporting methods are not observed as this implementation uses the MGO driver which does not support contexts.

func NewQueueReporter Uses

func NewQueueReporter(q amboy.Queue) Reporter

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 Uses

type RuntimeFilter string

RuntimeFilter provides ways to filter the timing data returned by the reporting interface.

func (RuntimeFilter) Validate Uses

func (t RuntimeFilter) Validate() error

Validate returns an error if a filter value is not valid.

Package reporting imports 8 packages (graph) and is imported by 5 packages. Updated 2018-09-24. Refresh now. Tools for package owners.