...

Package envconfig

import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig"
Overview
Index

Overview ▾

func WithDuration

func WithDuration(n string, fn func(time.Duration)) func(e *EnvOptionsReader)

WithDuration retrieves the specified config and passes it to ConfigFn as a duration.

func WithHeaders

func WithHeaders(n string, fn func(map[string]string)) func(e *EnvOptionsReader)

WithHeaders retrieves the specified config and passes it to ConfigFn as a map of HTTP headers.

func WithString

func WithString(n string, fn func(string)) func(e *EnvOptionsReader)

WithString retrieves the specified config and passes it to ConfigFn as a string.

func WithURL

func WithURL(n string, fn func(*url.URL)) func(e *EnvOptionsReader)

WithURL retrieves the specified config and passes it to ConfigFn as a net/url.URL.

type ConfigFn

ConfigFn is the generic function used to set a config.

type ConfigFn func(*EnvOptionsReader)

func WithBool

func WithBool(n string, fn func(bool)) ConfigFn

WithBool returns a ConfigFn that reads the environment variable n and if it exists passes its parsed bool value to fn.

func WithCertPool

func WithCertPool(n string, fn func(*x509.CertPool)) ConfigFn

WithCertPool returns a ConfigFn that reads the environment variable n as a filepath to a TLS certificate pool. If it exists, it is parsed as a crypto/x509.CertPool and it is passed to fn.

func WithClientCert

func WithClientCert(nc, nk string, fn func(tls.Certificate)) ConfigFn

WithClientCert returns a ConfigFn that reads the environment variable nc and nk as filepaths to a client certificate and key pair. If they exists, they are parsed as a crypto/tls.Certificate and it is passed to fn.

type EnvOptionsReader

EnvOptionsReader reads the required environment variables.

type EnvOptionsReader struct {
    GetEnv    func(string) string
    ReadFile  func(string) ([]byte, error)
    Namespace string
}

func (*EnvOptionsReader) Apply

func (e *EnvOptionsReader) Apply(opts ...ConfigFn)

Apply runs every ConfigFn.

func (*EnvOptionsReader) GetEnvValue

func (e *EnvOptionsReader) GetEnvValue(key string) (string, bool)

GetEnvValue gets an OTLP environment variable value of the specified key using the GetEnv function. This function prepends the OTLP specified namespace to all key lookups.