otest

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunClientTests

func RunClientTests(f ClientFactory) func(*testing.T)

RunClientTests runs a suite of Client integration tests. For example:

t.Run("Integration", RunClientTests(factory))

Types

type ClientFactory

type ClientFactory func() (otlpmetric.Client, Collector)

ClientFactory is a function that when called returns a otlpmetric.Client implementation that is connected to also returned Collector implementation. The Client is ready to upload metric data to the Collector which is ready to store that data.

type Collector

type Collector interface {
	Collect() *Storage
}

Collector is the collection target a Client sends metric uploads to.

type GRPCCollector

type GRPCCollector struct {
	collpb.UnimplementedMetricsServiceServer
	// contains filtered or unexported fields
}

GRPCCollector is an OTLP gRPC server that collects all requests it receives.

func NewGRPCCollector

func NewGRPCCollector(endpoint string, errCh <-chan error) (*GRPCCollector, error)

NewGRPCCollector returns a *GRPCCollector that is listening at the provided endpoint.

If endpoint is an empty string, the returned collector will be listeing on the localhost interface at an OS chosen port.

If errCh is not nil, the collector will respond to Export calls with errors sent on that channel. This means that if errCh is not nil Export calls will block until an error is received.

func (*GRPCCollector) Addr

func (c *GRPCCollector) Addr() net.Addr

Addr returns the net.Addr c is listening at.

func (*GRPCCollector) Collect

func (c *GRPCCollector) Collect() *Storage

Collect returns the Storage holding all collected requests.

func (*GRPCCollector) Export

Export handles the export req.

func (*GRPCCollector) Headers

func (c *GRPCCollector) Headers() map[string][]string

Headers returns the headers received for all requests.

func (*GRPCCollector) Shutdown

func (c *GRPCCollector) Shutdown()

Shutdown shuts down the gRPC server closing all open connections and listeners immediately.

type HTTPCollector

type HTTPCollector struct {
	// contains filtered or unexported fields
}

HTTPCollector is an OTLP HTTP server that collects all requests it receives.

func NewHTTPCollector

func NewHTTPCollector(endpoint string, errCh <-chan error) (*HTTPCollector, error)

NewHTTPCollector returns a *HTTPCollector that is listening at the provided endpoint.

If endpoint is an empty string, the returned collector will be listeing on the localhost interface at an OS chosen port, not use TLS, and listen at the default OTLP metric endpoint path ("/v1/metrics"). If the endpoint contains a prefix of "https" the server will generate weak self-signed TLS certificates and use them to server data. If the endpoint contains a path, that path will be used instead of the default OTLP metric endpoint path.

If errCh is not nil, the collector will respond to HTTP requests with errors sent on that channel. This means that if errCh is not nil Export calls will block until an error is received.

func (*HTTPCollector) Addr

func (c *HTTPCollector) Addr() net.Addr

Addr returns the net.Addr c is listening at.

func (*HTTPCollector) Collect

func (c *HTTPCollector) Collect() *Storage

Collect returns the Storage holding all collected requests.

func (*HTTPCollector) Headers

func (c *HTTPCollector) Headers() map[string][]string

Headers returns the headers received for all requests.

func (*HTTPCollector) Shutdown

func (c *HTTPCollector) Shutdown(ctx context.Context) error

Shutdown shuts down the HTTP server closing all open connections and listeners.

type HTTPResponseError

type HTTPResponseError struct {
	Err    error
	Status int
	Header http.Header
}

func (*HTTPResponseError) Error

func (e *HTTPResponseError) Error() string

func (*HTTPResponseError) Unwrap

func (e *HTTPResponseError) Unwrap() error

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage stores uploaded OTLP metric data in their proto form.

func NewStorage

func NewStorage() *Storage

NewStorage returns a configure storage ready to store received requests.

func (*Storage) Add

func (s *Storage) Add(request *collpb.ExportMetricsServiceRequest)

Add adds the request to the Storage.

func (*Storage) Dump

func (s *Storage) Dump() []*mpb.ResourceMetrics

Dump returns all added ResourceMetrics and clears the storage.

Jump to

Keyboard shortcuts

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