Documentation
¶
Overview ¶
Package otlpconfig provides configuration for the otlptrace exporters.
Index ¶
- Constants
- Variables
- func CreateTLSConfig(certBytes []byte) (*tls.Config, error)
- func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader)
- func WithEnvProtocol(n string, fn func(Protocol)) func(e *envconfig.EnvOptionsReader)
- type Compression
- type Config
- type GRPCOption
- type GenericOption
- func WithCompression(compression Compression) GenericOption
- func WithEndpoint(endpoint string) GenericOption
- func WithEndpointURL(v string) GenericOption
- func WithHTTPClient(c *http.Client) GenericOption
- func WithHeaders(headers map[string]string) GenericOption
- func WithInsecure() GenericOption
- func WithMaxRequestSize(size int) GenericOption
- func WithProtocol(protocol Protocol) GenericOption
- func WithProxy(pf HTTPTransportProxyFunc) GenericOption
- func WithRetry(rc retry.Config) GenericOption
- func WithSecure() GenericOption
- func WithTLSClientConfig(tlsCfg *tls.Config) GenericOption
- func WithTimeout(duration time.Duration) GenericOption
- func WithURLPath(urlPath string) GenericOption
- type HTTPOption
- type HTTPTransportProxyFunc
- type Marshaler
- type Protocol
- type SignalConfig
Constants ¶
const ( // DefaultTracesPath is a default URL path for endpoint that // receives spans. DefaultTracesPath string = "/v1/traces" // DefaultMaxRequestSize is the default maximum size of a serialized export // request, before compression. DefaultMaxRequestSize int = 64 * 1024 * 1024 // DefaultMaxResponseSize is the default maximum size of an OTLP/HTTP // response body, after decompression. DefaultMaxResponseSize int64 = 4 * 1024 * 1024 // DefaultTimeout is a default max waiting time for the backend to process // each span batch. DefaultTimeout time.Duration = 10 * time.Second )
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 ¶
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{ GetEnv: os.Getenv, ReadFile: os.ReadFile, Namespace: "OTEL_EXPORTER_OTLP", }
DefaultEnvOptionsReader is the default environments reader.
Functions ¶
func CreateTLSConfig ¶
CreateTLSConfig creates a tls.Config from a raw certificate bytes 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.
func WithEnvProtocol ¶ added in v1.46.0
func WithEnvProtocol(n string, fn func(Protocol)) func(e *envconfig.EnvOptionsReader)
WithEnvProtocol retrieves the specified config and passes it to ConfigFn as a Protocol.
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
Traces SignalConfig
RetryConfig retry.Config
// gRPC configurations
ReconnectionPeriod time.Duration
ServiceConfig string
DialOptions []grpc.DialOption
GRPCConn *grpc.ClientConn
}
Config holds the configuration for an otlptrace exporter.
func ApplyGRPCEnvConfigs ¶
ApplyGRPCEnvConfigs applies the env configurations for gRPC.
func ApplyHTTPEnvConfigs ¶
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
NewGRPCOption creates an option that is only applied to the gRPC driver.
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
WithCompression configures the compression used for exports.
func WithEndpoint ¶
func WithEndpoint(endpoint string) GenericOption
WithEndpoint configures the trace host and port only; endpoint should resemble "example.com" or "localhost:4317". To configure the scheme and path, use WithEndpointURL.
func WithEndpointURL ¶ added in v1.23.0
func WithEndpointURL(v string) GenericOption
WithEndpointURL configures the trace scheme, host, port, and path; the provided value should resemble "https://example.com:4318/v1/traces".
func WithHTTPClient ¶ added in v1.36.0
func WithHTTPClient(c *http.Client) GenericOption
WithHTTPClient configures the HTTP client used to make requests.
func WithHeaders ¶
func WithHeaders(headers map[string]string) GenericOption
WithHeaders configures headers sent with every export request.
func WithInsecure ¶
func WithInsecure() GenericOption
WithInsecure disables client transport security for the exporter's connection.
func WithMaxRequestSize ¶ added in v1.44.0
func WithMaxRequestSize(size int) GenericOption
WithMaxRequestSize configures the maximum size, in bytes, of a serialized export request, before compression.
func WithProtocol ¶ added in v1.46.0
func WithProtocol(protocol Protocol) GenericOption
WithProtocol configures the protocol used to encode and send telemetry.
func WithProxy ¶ added in v1.25.0
func WithProxy(pf HTTPTransportProxyFunc) GenericOption
WithProxy configures the proxy function used by the exporter's HTTP client.
func WithRetry ¶
func WithRetry(rc retry.Config) GenericOption
WithRetry configures the retry policy used on failed exports.
func WithSecure ¶
func WithSecure() GenericOption
WithSecure enables client transport security for the exporter's connection.
func WithTLSClientConfig ¶
func WithTLSClientConfig(tlsCfg *tls.Config) GenericOption
WithTLSClientConfig configures the TLS configuration used by the exporter's client.
func WithTimeout ¶
func WithTimeout(duration time.Duration) GenericOption
WithTimeout configures the max waiting time for the backend to process each export batch.
func WithURLPath ¶
func WithURLPath(urlPath string) GenericOption
WithURLPath configures the URL path the exporter sends requests to.
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
NewHTTPOption creates an option that is only applied to the HTTP driver.
func WithMaxResponseSize ¶ added in v1.47.0
func WithMaxResponseSize(size int64) HTTPOption
WithMaxResponseSize configures the maximum size, in bytes, of an OTLP/HTTP response body, after decompression.
type HTTPTransportProxyFunc ¶ added in v1.25.0
HTTPTransportProxyFunc is a function that resolves which URL to use as proxy for a given request. This type is compatible with `http.Transport.Proxy` and can be used to set a custom proxy function to the OTLP HTTP client.
type Marshaler ¶
type Marshaler int
Marshaler describes the kind of message format sent to the collector.
type Protocol ¶ added in v1.46.0
type Protocol int
Protocol describes the transport protocol used to send data to the collector.
type SignalConfig ¶
type SignalConfig struct {
Endpoint string
Insecure bool
TLSCfg *tls.Config
Headers map[string]string
Compression Compression
Protocol Protocol
MaxRequestSize int
MaxResponseSize int64
Timeout time.Duration
URLPath string
// gRPC configurations
GRPCCredentials credentials.TransportCredentials
// HTTP configurations
Proxy HTTPTransportProxyFunc
HTTPClient *http.Client
}
SignalConfig holds the configuration for exporting a single signal.