asyncexporter

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultCollectorPort is the port the Exporter will attempt connect to
	// if no collector port is provided.
	DefaultCollectorPort uint16 = 55680
	// DefaultCollectorHost is the host address the Exporter will attempt
	// connect to if no collector address is provided.
	DefaultCollectorHost string = "localhost"
	// DefaultNumWorkers is the number of goroutines the Exporter will use when
	// processing telemetry.
	DefaultNumWorkers uint = 1

	// DefaultGRPCServiceConfig is the gRPC service config used if none is
	// provided by the user.
	//
	// For more info on gRPC service configs:
	// https://github.com/grpc/proposal/blob/master/A6-client-retries.md
	//
	// Note: MaxAttempts > 5 are treated as 5. See
	// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#validation-of-retrypolicy
	// for more details.
	DefaultGRPCServiceConfig = `` /* 497-byte string literal not displayed */

	MaxExportBatchSize = 512
)

Variables

View Source
var (
	// Concurrency number of concurrent log reports
	Concurrency int = 1
	// QueueSize log queue cache length. values less than 2048 are invalid.
	QueueSize int = 2048
)

Functions

This section is empty.

Types

type Exporter

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

Exporter exports telemetry data from the collector to a destination.

func NewExporter

func NewExporter(opts ...ExporterOption) (*Exporter, error)

NewExporter constructs a new Exporter and starts it.

func NewUnstartedExporter

func NewUnstartedExporter(opts ...ExporterOption) *Exporter

NewUnstartedExporter constructs a new Exporter and does not start it.

func (*Exporter) ExportLogs

func (e *Exporter) ExportLogs(parent context.Context, logs []*logsproto.ResourceLogs) error

ExportLogs export log

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(ctx context.Context) error

Shutdown closes all connections and releases resources currently being used by the exporter. If the exporter is not started this does nothing.

func (*Exporter) Start

func (e *Exporter) Start() error

Start dials to the collector, establishing a connection to it. It also initiates the Config and Trace services by sending over the initial messages that consist of the node identifier. Start invokes a background connector that will reattempt connections to the collector periodically if the connection dies.

type ExporterOption

type ExporterOption func(*config)

ExporterOption are setting options passed to an Exporter on creation.

func WithAddress

func WithAddress(addr string) ExporterOption

WithAddress allows one to set the address that the exporter will connect to the collector on. If unset, it will instead try to use connect to DefaultCollectorHost:DefaultCollectorPort.

func WithCompressor

func WithCompressor(compressor string) ExporterOption

WithCompressor will set the compressor for the gRPC client to use when sending requests. It is the responsibility of the caller to ensure that the compressor set has been registered with google.golang.org/grpc/encoding. This can be done by encoding.RegisterCompressor. Some compressors auto-register on import, such as gzip, which can be registered by calling `import _ "google.golang.org/grpc/encoding/gzip"`

func WithConcurrency

func WithConcurrency(concurrency int) ExporterOption

WithConcurrency define the number of goroutines to export logs

func WithGRPCDialOption

func WithGRPCDialOption(opts ...grpc.DialOption) ExporterOption

WithGRPCDialOption opens support to any grpc.DialOption to be used. If it conflicts with some other configuration the GRPC specified via the collector the ones here will take preference since they are set last.

func WithGRPCServiceConfig

func WithGRPCServiceConfig(serviceConfig string) ExporterOption

WithGRPCServiceConfig defines the default gRPC service config used.

func WithHeaders

func WithHeaders(headers map[string]string) ExporterOption

WithHeaders will send the provided headers with gRPC requests

func WithInsecure

func WithInsecure() ExporterOption

WithInsecure disables client transport security for the exporter's gRPC connection just like grpc.WithInsecure() https://pkg.go.dev/google.golang.org/grpc#WithInsecure does. Note, by default, client security is required unless WithInsecure is used.

func WithReconnectionPeriod

func WithReconnectionPeriod(rp time.Duration) ExporterOption

WithReconnectionPeriod allows one to set the delay between next connection attempt after failing to connect with the collector.

func WithTLSCredentials

func WithTLSCredentials(creds credentials.TransportCredentials) ExporterOption

WithTLSCredentials allows the connection to use TLS credentials when talking to the server. It takes in grpc.TransportCredentials instead of say a Certificate file or a tls.Certificate, because the retrieving these credentials can be done in many ways e.g. plain file, in code tls.Config or by certificate rotation, so it is up to the caller to decide what to use.

func WithTenantID

func WithTenantID(tenantID string) ExporterOption

WithTenantID will set 'X-Tps-TenantID' as grpc header

func WorkerCount

func WorkerCount(n uint) ExporterOption

WorkerCount sets the number of Goroutines to use when processing telemetry.

Jump to

Keyboard shortcuts

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