oconf

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxAttempts describes how many times the driver
	// should retry the sending of the payload in case of a
	// retryable error.
	DefaultMaxAttempts int = 5
	// DefaultMetricsPath is a default URL path for endpoint that
	// receives metrics.
	DefaultMetricsPath string = "/v1/metrics"
	// DefaultBackoff is a default base backoff time used in the
	// exponential backoff strategy.
	DefaultBackoff time.Duration = 300 * time.Millisecond
	// DefaultTimeout is a default max waiting time for the backend to process
	// each span or metrics batch.
	DefaultTimeout time.Duration = 10 * time.Second
)
View Source
const (
	// DefaultCollectorGRPCPort is the default gRPC port of the collector.
	DefaultCollectorGRPCPort uint16 = 4317
	// DefaultCollectorHTTPPort is the default HTTP port of the collector.
	DefaultCollectorHTTPPort uint16 = 4318
	// DefaultCollectorHost is the host address the Exporter will attempt
	// connect to if no collector address is provided.
	DefaultCollectorHost string = "localhost"
)

Variables

View Source
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{
	GetEnv:    os.Getenv,
	ReadFile:  os.ReadFile,
	Namespace: "OTEL_EXPORTER_OTLP",
}

DefaultEnvOptionsReader is the default environments reader.

Functions

func CreateTLSConfig

func CreateTLSConfig(certBytes []byte) (*tls.Config, error)

CreateTLSConfig creates a tls.Config from a raw certificate bytes to verify a server certificate.

func ReadTLSConfigFromFile

func ReadTLSConfigFromFile(path string) (*tls.Config, error)

ReadTLSConfigFromFile reads a PEM certificate file and creates a tls.Config that will use this certifate to verify a server certificate.

func WithEnvCompression

func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader)

WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression.

Types

type Compression

type Compression int

Compression describes the compression used for payloads sent to the collector.

const (
	// NoCompression tells the driver to send payloads without
	// compression.
	NoCompression Compression = iota
	// GzipCompression tells the driver to send payloads after
	// compressing them with gzip.
	GzipCompression
)

type Config

type Config struct {
	// Signal specific configurations
	Metrics SignalConfig

	RetryConfig retry.Config

	// gRPC configurations
	ReconnectionPeriod time.Duration
	ServiceConfig      string
	DialOptions        []grpc.DialOption
	GRPCConn           *grpc.ClientConn
}

func ApplyGRPCEnvConfigs

func ApplyGRPCEnvConfigs(cfg Config) Config

ApplyGRPCEnvConfigs applies the env configurations for gRPC.

func ApplyHTTPEnvConfigs

func ApplyHTTPEnvConfigs(cfg Config) Config

ApplyHTTPEnvConfigs applies the env configurations for HTTP.

func NewGRPCConfig

func NewGRPCConfig(opts ...GRPCOption) Config

NewGRPCConfig returns a new Config with all settings applied from opts and any unset setting using the default gRPC config values.

func NewHTTPConfig

func NewHTTPConfig(opts ...HTTPOption) Config

NewHTTPConfig returns a new Config with all settings applied from opts and any unset setting using the default HTTP config values.

type GRPCOption

type GRPCOption interface {
	ApplyGRPCOption(Config) Config
	// contains filtered or unexported methods
}

GRPCOption applies an option to the gRPC driver.

func NewGRPCOption

func NewGRPCOption(fn func(cfg Config) Config) GRPCOption

type GenericOption

type GenericOption interface {
	ApplyHTTPOption(Config) Config
	ApplyGRPCOption(Config) Config
	// contains filtered or unexported methods
}

GenericOption applies an option to the HTTP or gRPC driver.

func WithCompression

func WithCompression(compression Compression) GenericOption

func WithEndpoint

func WithEndpoint(endpoint string) GenericOption

func WithHeaders

func WithHeaders(headers map[string]string) GenericOption

func WithInsecure

func WithInsecure() GenericOption

func WithRetry

func WithRetry(rc retry.Config) GenericOption

func WithSecure

func WithSecure() GenericOption

func WithTLSClientConfig

func WithTLSClientConfig(tlsCfg *tls.Config) GenericOption

func WithTimeout

func WithTimeout(duration time.Duration) GenericOption

func WithURLPath

func WithURLPath(urlPath string) GenericOption

type HTTPOption

type HTTPOption interface {
	ApplyHTTPOption(Config) Config
	// contains filtered or unexported methods
}

HTTPOption applies an option to the HTTP driver.

func NewHTTPOption

func NewHTTPOption(fn func(cfg Config) Config) HTTPOption

type RetrySettings

type RetrySettings struct {
	// Enabled indicates whether to not retry sending batches in case of export failure.
	Enabled bool
	// InitialInterval the time to wait after the first failure before retrying.
	InitialInterval time.Duration
	// MaxInterval is the upper bound on backoff interval. Once this value is reached the delay between
	// consecutive retries will always be `MaxInterval`.
	MaxInterval time.Duration
	// MaxElapsedTime is the maximum amount of time (including retries) spent trying to send a request/batch.
	// Once this value is reached, the data is discarded.
	MaxElapsedTime time.Duration
}

RetrySettings defines configuration for retrying batches in case of export failure using an exponential backoff.

type SignalConfig

type SignalConfig struct {
	Endpoint    string
	Insecure    bool
	TLSCfg      *tls.Config
	Headers     map[string]string
	Compression Compression
	Timeout     time.Duration
	URLPath     string

	// gRPC configurations
	GRPCCredentials credentials.TransportCredentials
}

Jump to

Keyboard shortcuts

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