transporttest

package
v0.0.0-...-8b7d6bd Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package transporttest provides implementations of transport.Transport for testing purposes.

Index

Constants

This section is empty.

Variables

Discard is a transport.Transport which discards all streams, and returns no errors.

Functions

This section is empty.

Types

type ErrorTransport

type ErrorTransport struct {
	Error error
}

ErrorTransport is a transport that returns the stored error for each method call.

func (ErrorTransport) SendStream

func (t ErrorTransport) SendStream(ctx context.Context, r io.Reader) error

SendStream discards the stream and returns t.Error.

type Payloads

type Payloads struct {
	Errors       []model.Error
	Metrics      []model.Metrics
	Spans        []model.Span
	Transactions []model.Transaction
	Profiles     [][]byte
}

Payloads holds the recorded payloads.

func (*Payloads) Len

func (p *Payloads) Len() int

Len returns the number of recorded payloads.

type RecorderTransport

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

RecorderTransport implements transport.Transport, recording the streams sent. The streams can be retrieved using the Payloads method.

func NewRecorderTracer

func NewRecorderTracer() (*apm.Tracer, *RecorderTransport)

NewRecorderTracer returns a new apm.Tracer and RecorderTransport, which is set as the tracer's transport.

DEPRECATED. Use apmtest.NewRecordingTracer instead.

func (*RecorderTransport) CloudMetadata

func (r *RecorderTransport) CloudMetadata() model.Cloud

CloudMetadata returns the cloud metadata recorded by the transport. If metadata is yet to be received, this method will panic.

TODO(axw) remove when Metadata returns an exported type containing all metadata.

func (*RecorderTransport) Metadata

func (r *RecorderTransport) Metadata() (_ model.System, _ model.Process, _ model.Service, labels model.IfaceMap)

Metadata returns the metadata recorded by the transport. If metadata is yet to be received, this method will panic.

TODO(axw) introduce an exported type which contains all metadata, and return that. Although we don't guarantee stability for this package this has a high probability of breaking existing external tests, so let's do that in v2.

func (*RecorderTransport) Payloads

func (r *RecorderTransport) Payloads() Payloads

Payloads returns the payloads recorded by SendStream.

func (*RecorderTransport) ResetPayloads

func (r *RecorderTransport) ResetPayloads()

ResetPayloads clears out any recorded payloads.

func (*RecorderTransport) SendProfile

func (r *RecorderTransport) SendProfile(ctx context.Context, metadata io.Reader, profiles ...io.Reader) error

SendProfile records the stream such that it can later be obtained via Payloads.

func (*RecorderTransport) SendStream

func (r *RecorderTransport) SendStream(ctx context.Context, stream io.Reader) error

SendStream records the stream such that it can later be obtained via Payloads.

Jump to

Keyboard shortcuts

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