tracing

package
v1.2.3-fred.12 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultExporterDialTimeout is the default timeout for dialing the exporter.
	DefaultExporterDialTimeout = 5 * time.Second

	// VersionKey is the attribute key for the teleport version.
	VersionKey = "teleport.version"

	// ProcessIDKey is attribute key for the process ID.
	ProcessIDKey = "teleport.process.id"

	// HostnameKey is the attribute key for the hostname.
	HostnameKey = "teleport.host.name"

	// HostIDKey is the attribute key for the host UUID.
	HostIDKey = "teleport.host.uuid"
)
View Source
const DefaultFileLimit uint64 = 1048576 * 100 // 100MB

DefaultFileLimit is the default file size limit used before rotating to a new traces file

Variables

View Source
var ErrShutdown = errors.New("the client is shutdown")

Functions

func NewClient

func NewClient(cfg Config) (otlptrace.Client, error)

NewClient either returns the provided Config.Client or constructs a new client that is connected to the Config.ExporterURL with the appropriate TLS credentials. The returned client is not started, it will be started by the provider if passed to one.

func NewExporter

func NewExporter(ctx context.Context, cfg Config) (sdktrace.SpanExporter, error)

NewExporter returns a new exporter that is configured per the provided Config.

func NewNoopClient

func NewNoopClient() otlptrace.Client

NewNoopClient returns an oltptrace.Client that does nothing

func NewStartedClient

func NewStartedClient(ctx context.Context, cfg Config) (otlptrace.Client, error)

NewStartedClient either returns the provided Config.Client or constructs a new client that is connected to the Config.ExporterURL with the appropriate TLS credentials. The client is started prior to returning to the caller.

func NoopTracer

func NoopTracer(instrumentationName string) oteltrace.Tracer

NoopTracer creates a new Tracer that never samples any spans.

Types

type Collector

type Collector struct {
	coltracepb.TraceServiceServer
	// contains filtered or unexported fields
}

Collector is a simple in memory implementation of an OpenTelemetry Collector that is used for testing purposes.

func NewCollector

func NewCollector(cfg CollectorConfig) (*Collector, error)

NewCollector creates a new Collector based on the provided config.

func (*Collector) ClientTLSConfig

func (c *Collector) ClientTLSConfig() *tls.Config

ClientTLSConfig returns the tls.Config that clients should use to connect to the collector.

func (*Collector) Export

Export is the grpc handler for the Collector.

func (*Collector) GRPCAddr

func (c *Collector) GRPCAddr() string

GRPCAddr is the ExporterURL that the gRPC server is listening on.

func (*Collector) HTTPAddr

func (c *Collector) HTTPAddr() string

HTTPAddr is the ExporterURL that the HTTP server is listening on.

func (*Collector) HTTPSAddr

func (c *Collector) HTTPSAddr() string

HTTPSAddr is the ExporterURL that the HTTPS server is listening on.

func (*Collector) ServeHTTP

func (c *Collector) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the HTTP handler for the Collector.

func (*Collector) Shutdown

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

Shutdown stops the gRPC and HTTP servers.

func (*Collector) Spans

func (c *Collector) Spans() []*otlp.ScopeSpans

func (*Collector) Start

func (c *Collector) Start() error

Start starts the gRPC and HTTP servers.

type CollectorConfig

type CollectorConfig struct {
	TLSConfig *tls.Config
}

CollectorConfig configures how a Collector should be created.

type Config

type Config struct {
	// Service is the name of the service that will be reported to the tracing system.
	Service string
	// Attributes is a set of key value pairs that will be added to all spans.
	Attributes []attribute.KeyValue
	// ExporterURL is the URL of the exporter.
	ExporterURL string
	// SamplingRate determines how many spans are recorded and exported
	SamplingRate float64
	// TLSCert is the TLS configuration to use for the exporter.
	TLSConfig *tls.Config
	// DialTimeout is the timeout for dialing the exporter.
	DialTimeout time.Duration
	// Logger is the logger to use.
	Logger logrus.FieldLogger
	// Client is the client to use to export traces. This takes precedence over creating a
	// new client with the ExporterURL. Ownership of the client is transferred to the
	// tracing provider. It should **NOT** be closed by the caller.
	Client *tracing.Client
	// contains filtered or unexported fields
}

Config used to set up the tracing exporter and provider

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

CheckAndSetDefaults checks the config and sets default values.

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint provides the properly formatted endpoint that the otlp client libraries are expecting.

type Provider

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

Provider wraps the OpenTelemetry tracing provider to provide common tags for all tracers.

func NewTraceProvider

func NewTraceProvider(ctx context.Context, cfg Config) (*Provider, error)

NewTraceProvider creates a new Provider that is configured per the provided Config.

func NoopProvider

func NoopProvider() *Provider

NoopProvider creates a new Provider that never samples any spans.

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown shuts down the span processors in the order they were registered.

func (*Provider) Tracer

func (p *Provider) Tracer(instrumentationName string, opts ...oteltrace.TracerOption) oteltrace.Tracer

Tracer returns a Tracer with the given name and options. If a Tracer for the given name and options does not exist it is created, otherwise the existing Tracer is returned.

If name is empty, DefaultTracerName is used instead.

This method is safe to be called concurrently.

type RotatingFileClient

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

RotatingFileClient is an otlptrace.Client that writes traces to a file. It will automatically rotate files when they reach the configured limit. Each line in the file is a JSON-encoded otlp.Span.

func NewRotatingFileClient

func NewRotatingFileClient(dir string, limit uint64) (*RotatingFileClient, error)

NewRotatingFileClient returns a new RotatingFileClient that will store files in the provided directory. The files will be rotated when they reach the provided limit.

func (*RotatingFileClient) Start

func (f *RotatingFileClient) Start(ctx context.Context) error

Start is a noop needed to satisfy the otlptrace.Client interface.

func (*RotatingFileClient) Stop

func (f *RotatingFileClient) Stop(ctx context.Context) error

Stop closes the active file and sets it to nil to indicate to UploadTraces that no more traces should be written.

func (*RotatingFileClient) UploadTraces

func (f *RotatingFileClient) UploadTraces(ctx context.Context, protoSpans []*otlp.ResourceSpans) error

UploadTraces writes the provided spans to a file in the configured directory. If writing another span to the file would cause it to exceed the limit, then the file is first rotated before the write is attempted. In the event that Stop has already been called this will always return ErrShutdown.

Jump to

Keyboard shortcuts

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