package view

Import Path
	go.opencensus.io/stats/view (on go.dev)

Dependency Relation
	imports 17 packages, and imported by 13 packages

Involved Source Files aggregation.go aggregation_data.go collector.go Package view contains support for collecting and exposing aggregates over stats. In order to collect measurements, views need to be defined and registered. A view allows recorded measurements to be filtered and aggregated. All recorded measurements can be grouped by a list of tags. OpenCensus provides several aggregation methods: Count, Distribution and Sum. Count only counts the number of measurement points recorded. Distribution provides statistical summary of the aggregated data by counting how many recorded measurements fall into each bucket. Sum adds up the measurement values. LastValue just keeps track of the most recently recorded measurement value. All aggregations are cumulative. Views can be registered and unregistered at any time during program execution. Libraries can define views but it is recommended that in most cases registering views be left up to applications. Exporting Collected and aggregated data can be exported to a metric collection backend by registering its exporter. Multiple exporters can be registered to upload the data to various different back ends. export.go view.go view_to_metric.go worker.go worker_commands.go
Code Examples package main import ( "go.opencensus.io/stats" "go.opencensus.io/stats/view" "log" ) func main() { // Measures are usually declared and used by instrumented packages. m := stats.Int64("example.com/measure/openconns", "open connections", stats.UnitDimensionless) // Views are usually registered in your application main function. if err := view.Register(&view.View{ Name: "example.com/views/openconns", Description: "open connections", Measure: m, Aggregation: view.Distribution(0, 1000, 2000), }); err != nil { log.Fatal(err) } // Use view.RegisterExporter to export collected data. }
Package-Level Type Names (total 25, in which 12 are exported)
/* sort exporteds by: | */
Aggregation represents a data aggregation method. Use one of the functions: Count, Sum, or Distribution to construct an Aggregation. // Buckets are the bucket endpoints if this Aggregation represents a distribution, see Distribution. // Type is the AggType of this Aggregation. func Count() *Aggregation func Distribution(bounds ...float64) *Aggregation func LastValue() *Aggregation func Sum() *Aggregation var go.opencensus.io/plugin/ocgrpc.DefaultBytesDistribution *Aggregation var go.opencensus.io/plugin/ocgrpc.DefaultMessageCountDistribution *Aggregation var go.opencensus.io/plugin/ocgrpc.DefaultMillisecondsDistribution *Aggregation var go.opencensus.io/plugin/ochttp.DefaultLatencyDistribution *Aggregation var go.opencensus.io/plugin/ochttp.DefaultSizeDistribution *Aggregation var contrib.go.opencensus.io/integrations/ocsql.DefaultMillisecondsDistribution *Aggregation
AggregationData represents an aggregated value from a collection. They are reported on the view data during exporting. Mosts users won't directly access aggregration data. *CountData *DistributionData *LastValueData *SumData
AggType represents the type of aggregation function used on a View. ( T) String() string T : expvar.Var T : fmt.Stringer const AggTypeCount const AggTypeDistribution const AggTypeLastValue const AggTypeNone const AggTypeSum
CountData is the aggregated data for the Count aggregation. A count aggregation processes data and counts the recordings. Most users won't directly access count data. Value int64 *T : AggregationData
A Data is a set of rows about usage of the single measure associated with the given view. Each row is specific to a unique set of tags. End time.Time Rows []*Row Start time.Time View *View func Exporter.ExportView(viewData *Data) func contrib.go.opencensus.io/exporter/prometheus.(*Exporter).ExportView(vd *Data) func contrib.go.opencensus.io/exporter/stackdriver.(*Exporter).ExportView(vd *Data)
DistributionData is the aggregated data for the Distribution aggregation. Most users won't directly access distribution data. For a distribution with N bounds, the associated DistributionData will have N+1 buckets. // number of data points aggregated // number of occurrences per bucket ExemplarsPerBucket is slice the same length as CountPerBucket containing an exemplar for the associated bucket, or nil. // max value in the distribution // mean of the distribution // minimum value in the distribution // sum of the squared deviation from the mean Sum returns the sum of all samples collected. *T : AggregationData
Exporter exports the collected records as view data. The ExportView method should return quickly; if an Exporter takes a significant amount of time to process a Data, that work should be done on another goroutine. It is safe to assume that ExportView will not be called concurrently from multiple goroutines. The Data should not be modified. ( T) ExportView(viewData *Data) *contrib.go.opencensus.io/exporter/prometheus.Exporter *contrib.go.opencensus.io/exporter/stackdriver.Exporter func RegisterExporter(e Exporter) func UnregisterExporter(e Exporter) func Meter.RegisterExporter(Exporter) func Meter.UnregisterExporter(Exporter)
LastValueData returns the last value recorded for LastValue aggregation. Value float64 *T : AggregationData
Meter defines an interface which allows a single process to maintain multiple sets of metrics exports (intended for the advanced case where a single process wants to report metrics about multiple objects, such as multiple databases or HTTP services). Note that this is an advanced use case, and the static functions in this module should cover the common use cases. Find returns a registered view associated with this name. If no registered view is found, nil is returned. Record records a set of measurements associated with the given tags and attachments. The second argument is a `[]Measurement`. Register begins collecting data for the given views. Once a view is registered, it reports data to the registered exporters. RegisterExporter registers an exporter. Collected data will be reported via all the registered exporters. Once you no longer want data to be exported, invoke UnregisterExporter with the previously registered exporter. Binaries can register exporters, libraries shouldn't register exporters. RetrieveData gets a snapshot of the data collected for the the view registered with the given name. It is intended for testing only. SetReportingPeriod sets the interval between reporting aggregated views in the program. If duration is less than or equal to zero, it enables the default behavior. Note: each exporter makes different promises about what the lowest supported duration is. For example, the Stackdriver exporter recommends a value no lower than 1 minute. Consult each exporter per your needs. SetResource may be used to set the Resource associated with this registry. This is intended to be used in cases where a single process exports metrics for multiple Resources, typically in a multi-tenant situation. Start causes the Meter to start processing Record calls and aggregating statistics as well as exporting data. Stop causes the Meter to stop processing calls and terminate data export. Unregister the given views. Data will not longer be exported for these views after Unregister returns. It is not necessary to unregister from views you expect to collect for the duration of your program execution. UnregisterExporter unregisters an exporter. T : go.opencensus.io/stats.Recorder func NewMeter() Meter
Row is the collected value for a specific set of key value pairs a.k.a tags. Data AggregationData Tags []tag.Tag Equal returns true if both rows are equal. Tags are expected to be ordered by the key name. Even if both rows have the same tags but the tags appear in different orders it will return false. (*T) String() string *T : expvar.Var *T : fmt.Stringer func RetrieveData(viewName string) ([]*Row, error) func Meter.RetrieveData(viewName string) ([]*Row, error) func (*Row).Equal(other *Row) bool
SumData is the aggregated data for the Sum aggregation. A sum aggregation processes data and sums up the recordings. Most users won't directly access sum data. Value float64 *T : AggregationData
View allows users to aggregate the recorded stats.Measurements. Views need to be passed to the Register function before data will be collected and sent to Exporters. Aggregation is the aggregation function to apply to the set of Measurements. // Description is a human-readable description for this view. Measure is a stats.Measure to aggregate in this view. // Name of View. Must be unique. If unset, will default to the name of the Measure. TagKeys are the tag keys describing the grouping of this view. A single Row will be produced for each combination of associated tag values. WithName returns a copy of the View with a new name. This is useful for renaming views to cope with limitations placed on metric names by various backends. func Find(name string) (v *View) func Meter.Find(name string) *View func (*View).WithName(name string) *View func Register(views ...*View) error func Unregister(views ...*View) func Meter.Register(views ...*View) error func Meter.Unregister(views ...*View) func golang.org/x/pkgsite/internal/dcensus.Init(cfg *config.Config, views ...*View) error var go.opencensus.io/plugin/ocgrpc.ClientCompletedRPCsView *View var go.opencensus.io/plugin/ocgrpc.ClientReceivedBytesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ClientReceivedMessagesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ClientRoundtripLatencyView *View var go.opencensus.io/plugin/ocgrpc.ClientSentBytesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ClientSentMessagesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ClientServerLatencyView *View var go.opencensus.io/plugin/ocgrpc.ServerCompletedRPCsView *View var go.opencensus.io/plugin/ocgrpc.ServerLatencyView *View var go.opencensus.io/plugin/ocgrpc.ServerReceivedBytesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ServerReceivedMessagesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ServerSentBytesPerRPCView *View var go.opencensus.io/plugin/ocgrpc.ServerSentMessagesPerRPCView *View var go.opencensus.io/plugin/ochttp.ClientCompletedCount *View var go.opencensus.io/plugin/ochttp.ClientLatencyView *View var go.opencensus.io/plugin/ochttp.ClientReceivedBytesDistribution *View var go.opencensus.io/plugin/ochttp.ClientRequestBytesView *View var go.opencensus.io/plugin/ochttp.ClientRequestCountByMethod *View var go.opencensus.io/plugin/ochttp.ClientRequestCountView *View var go.opencensus.io/plugin/ochttp.ClientResponseBytesView *View var go.opencensus.io/plugin/ochttp.ClientResponseCountByStatusCode *View var go.opencensus.io/plugin/ochttp.ClientRoundtripLatencyDistribution *View var go.opencensus.io/plugin/ochttp.ClientSentBytesDistribution *View var go.opencensus.io/plugin/ochttp.ServerLatencyView *View var go.opencensus.io/plugin/ochttp.ServerRequestBytesView *View var go.opencensus.io/plugin/ochttp.ServerRequestCountByMethod *View var go.opencensus.io/plugin/ochttp.ServerRequestCountView *View var go.opencensus.io/plugin/ochttp.ServerResponseBytesView *View var go.opencensus.io/plugin/ochttp.ServerResponseCountByStatusCode *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientActiveConnectionsView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientCallsView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientIdleClosedView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientIdleConnectionsView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientLatencyView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientLifetimeClosedView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientOpenConnectionsView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientWaitCountView *View var contrib.go.opencensus.io/integrations/ocsql.SQLClientWaitDurationView *View var golang.org/x/pkgsite/internal/dcensus.ServerLatency *View var golang.org/x/pkgsite/internal/dcensus.ServerRequestCount *View var golang.org/x/pkgsite/internal/dcensus.ServerResponseBytes *View var golang.org/x/pkgsite/internal/dcensus.ServerResponseCount *View var golang.org/x/pkgsite/internal/fetch.FetchLatencyDistribution *View var golang.org/x/pkgsite/internal/fetch.FetchPackageCount *View var golang.org/x/pkgsite/internal/fetch.FetchResponseCount *View var golang.org/x/pkgsite/internal/fetch.SheddedFetchCount *View var golang.org/x/pkgsite/internal/frontend.FetchLatencyDistribution *View var golang.org/x/pkgsite/internal/frontend.FetchResponseCount *View var golang.org/x/pkgsite/internal/frontend.VersionTypeCount *View var golang.org/x/pkgsite/internal/middleware.CacheErrorCount *View var golang.org/x/pkgsite/internal/middleware.CacheLatency *View var golang.org/x/pkgsite/internal/middleware.CacheResultCount *View var golang.org/x/pkgsite/internal/middleware.QuotaResultCount *View var golang.org/x/pkgsite/internal/postgres.SearchLatencyDistribution *View var golang.org/x/pkgsite/internal/postgres.SearchResponseCount *View var golang.org/x/pkgsite/internal/worker.EnqueueResponseCount *View var golang.org/x/pkgsite/internal/worker.ProcessingLag *View
Package-Level Functions (total 30, in which 12 are exported)
Count indicates that data collected and aggregated with this method will be turned into a count value. For example, total number of accepted requests can be aggregated by using Count.
Distribution indicates that the desired aggregation is a histogram distribution. A distribution aggregation may contain a histogram of the values in the population. The bucket boundaries for that histogram are described by the bounds. This defines len(bounds)+1 buckets. If len(bounds) >= 2 then the boundaries for bucket index i are: [-infinity, bounds[i]) for i = 0 [bounds[i-1], bounds[i]) for 0 < i < length [bounds[i-1], +infinity) for i = length If len(bounds) is 0 then there is no histogram associated with the distribution. There will be a single bucket with boundaries (-infinity, +infinity). If len(bounds) is 1 then there is no finite buckets, and that single element is the common boundary of the overflow and underflow buckets.
Find returns a registered view associated with this name. If no registered view is found, nil is returned.
LastValue only reports the last value recorded using this aggregation. All other measurements will be dropped.
NewMeter constructs a Meter instance. You should only need to use this if you need to separate out Measurement recordings and View aggregations within a single process.
Register begins collecting data for the given views. Once a view is registered, it reports data to the registered exporters.
RegisterExporter registers an exporter. Collected data will be reported via all the registered exporters. Once you no longer want data to be exported, invoke UnregisterExporter with the previously registered exporter. Binaries can register exporters, libraries shouldn't register exporters.
RetrieveData gets a snapshot of the data collected for the the view registered with the given name. It is intended for testing only.
SetReportingPeriod sets the interval between reporting aggregated views in the program. If duration is less than or equal to zero, it enables the default behavior. Note: each exporter makes different promises about what the lowest supported duration is. For example, the Stackdriver exporter recommends a value no lower than 1 minute. Consult each exporter per your needs.
Sum indicates that data collected and aggregated with this method will be summed up. For example, accumulated request bytes can be aggregated by using Sum.
Unregister the given views. Data will not longer be exported for these views after Unregister returns. It is not necessary to unregister from views you expect to collect for the duration of your program execution.
UnregisterExporter unregisters an exporter.
Package-Level Variables (total 6, in which 1 are exported)
ErrNegativeBucketBounds error returned if histogram contains negative bounds. Deprecated: this should not be public.
Package-Level Constants (total 7, in which 5 are exported)
All available aggregation types.
All available aggregation types.
All available aggregation types.
All available aggregation types.
All available aggregation types.