ocworkqueue

package module
v0.0.0-...-40aa506 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 6 Imported by: 6

README

OpenCensus Workqueue MetricsProvider

GoDoc

This package implements a k8s.io/client-go/util/workqueue.MetricsProvider backed by OpenCensus measurements.

Installation

$ go get -u github.com/0xRLG/ocworkqueue

The API of opencensus is still evolving, see their: Deprecation Policy. The use of vendoring or a dependency management tool is recommended.

Prerequisites

OpenCenusus requires Go 1.8 or later, therefor this project also requires Go 1.8 or later.

Usage

See the GoDoc for usage information.

Documentation

Overview

Package ocworkqueue contains support for extracting workqueue metrics with OpenCensus.

Example
package main

import (
	"github.com/0xRLG/ocworkqueue"
	"go.opencensus.io/stats/view"
	"k8s.io/client-go/util/workqueue"
)

func main() {

	// You must register the views to collect data.
	view.Register(ocworkqueue.DefaultViews...)

	// Register the metrics provider before you create the queue.
	workqueue.SetProvider(ocworkqueue.MetricsProvider())
	q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test_queue")

	// use the queue
	_ = q
}
Output:

Index

Examples

Constants

View Source
const (
	NameAttribute = "k8s.client-go.workqueue.name"
)

Variables

View Source
var (
	QueueDepth        = stats.Int64("opencensus.io/k8s/client-go/workqueue/depth", "Current depth of the workqueue", stats.UnitDimensionless)
	QueueAdds         = stats.Int64("opencensus.io/k8s/client-go/workqueue/adds", "Total number of items added to the queue", stats.UnitDimensionless)
	QueueLatency      = stats.Float64("opencensus.io/k8s/client-go/workqueue/latency", "How long an item stays in a workqueue", stats.UnitMilliseconds)
	QueueWorkDuration = stats.Float64("opencensus.io/k8s/client-go/workqueue/work_duration", "How long processing an item from a workqueue takes", stats.UnitMilliseconds)
	QueueRetries      = stats.Int64("opencensus.io/k8s/client-go/workqueue/retries", "Total number of items re-added to the workqueue", stats.UnitDimensionless)
)

This package provides the following Measures for use in custom views.

View Source
var (
	QueueDepthView = &view.View{
		Name:        "opencensus.io/k8s/client-go/workqueue/depth",
		Description: "Sum of items in the queue",
		Measure:     QueueDepth,
		TagKeys:     []tag.Key{Name},
		Aggregation: view.Sum(),
	}
	QueueAddsView = &view.View{
		Name:        "opencensus.io/k8s/client-go/workqueue/adds",
		Description: "Sum of items added to the queue",
		Measure:     QueueAdds,
		TagKeys:     []tag.Key{Name},
		Aggregation: view.Sum(),
	}
	QueueLatencyView = &view.View{
		Name:        "opencensus.io/k8s/client-go/workqueue/latency",
		Description: "Distribution of how long items stay in the workqueue",
		Measure:     QueueLatency,
		TagKeys:     []tag.Key{Name},
		Aggregation: DefaultMillisecondsDistribution,
	}
	QueueWorkDurationView = &view.View{
		Name:        "opencensus.io/k8s/client-go/workqueue/workduration",
		Description: "Distribution of how long items take to be processed",
		Measure:     QueueWorkDuration,
		TagKeys:     []tag.Key{Name},
		Aggregation: DefaultMillisecondsDistribution,
	}
	QueueRetriesView = &view.View{
		Name:        "opencensus.io/k8s/client-go/workqueue/retries",
		Description: "Sum of items re-added to the workqueue",
		Measure:     QueueRetries,
		TagKeys:     []tag.Key{Name},
		Aggregation: view.Sum(),
	}
)

This package provides the following convenience views. You must register views before any data is collected.

View Source
var DefaultMillisecondsDistribution = view.Distribution(0, 0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 50000, 100000)

The default distributions used by the views in this package.

DefaultViews are the default metrics exported by this package.

View Source
var (
	Name, _ = tag.NewKey(NameAttribute)
)

Name tag is determined by the name the queue is given when created.

Functions

func MetricsProvider

func MetricsProvider() workqueue.MetricsProvider

MetricsProvider returns an implementation of the workqueue metrics provider backed by opencensus measurements. This provider works with all of the metrics that the workqueue can export (Depth,Adds,Latency,WorkDuration,Retries)

You must register the views before any data is collected.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL