metricstest

package
v0.0.0-...-7cc1d6a Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCountData

func CheckCountData(t *testing.T, name string, wantTags map[string]string, wantValue int64)

CheckCountData checks the view with a name matching string name to verify that the CountData stats reported are tagged with the tags in wantTags and that wantValue matches reported count.

func CheckDistributionData

func CheckDistributionData(t *testing.T, name string, wantTags map[string]string, expectedCount int64, expectedMin float64, expectedMax float64)

CheckDistributionData checks the view with a name matching string name to verify that the DistributionData stats reported are tagged with the tags in wantTags and that expectedCount number of records were reported. It also checks that expectedMin and expectedMax match the minimum and maximum reported values, respectively.

func CheckLastValueData

func CheckLastValueData(t *testing.T, name string, wantTags map[string]string, wantValue float64)

CheckLastValueData checks the view with a name matching string name to verify that the LastValueData stats reported are tagged with the tags in wantTags and that wantValue matches reported last value.

func CheckStatsNotReported

func CheckStatsNotReported(t *testing.T, names ...string)

CheckStatsNotReported checks that there are no records for any views that a name matching a string in names. Names that do not match registered views are considered not reported.

func CheckStatsReported

func CheckStatsReported(t *testing.T, names ...string)

CheckStatsReported checks that there is a view registered with the given name for each string in names, and that each view has at least one record.

func CheckSumData

func CheckSumData(t *testing.T, name string, wantTags map[string]string, wantValue float64)

CheckSumData checks the view with a name matching string name to verify that the SumData stats reported are tagged with the tags in wantTags and that wantValue matches the reported sum.

func Unregister

func Unregister(names ...string)

Unregister unregisters the metrics that were registered. This is useful for testing since golang execute test iterations within the same process and opencensus views maintain global state. At the beginning of each test, tests should unregister for all metrics and then re-register for the same metrics. This effectively clears out any existing data and avoids a panic due to re-registering a metric.

In normal process shutdown, metrics do not need to be unregistered.

Types

This section is empty.

Jump to

Keyboard shortcuts

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