Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: various issues with API structs #102

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions api/telemetry/v1alpha1/otlp_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,101 +24,101 @@ import (
type TimeoutSettings struct {
// Timeout is the timeout for every attempt to send data to the backend.
// A zero timeout means no timeout.
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Timeout *time.Duration `json:"timeout,omitempty"`
}

// QueueSettings defines configuration for queueing batches before sending to the consumerSender.
type QueueSettings struct {
// Enabled indicates whether to not enqueue batches before sending to the consumerSender.
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
Enabled bool `json:"enabled,omitempty"`
// NumConsumers is the number of consumers from the queue.
NumConsumers int `json:"num_consumers,omitempty" yaml:"num_consumers,omitempty"`
NumConsumers int `json:"num_consumers,omitempty"`
// QueueSize is the maximum number of batches allowed in queue at a given time.
QueueSize int `json:"queue_size,omitempty" yaml:"queue_size,omitempty"`
QueueSize int `json:"queue_size,omitempty"`
// StorageID if not empty, enables the persistent storage and uses the component specified
// as a storage extension for the persistent queue
StorageID string `json:"storage,omitempty" yaml:"storage,omitempty"` //TODO this is *component.ID at Otel
StorageID string `json:"storage,omitempty"` //TODO this is *component.ID at Otel
}

// BackOffConfig defines configuration for retrying batches in case of export failure.
// The current supported strategy is exponential backoff.
type BackOffConfig struct {
// Enabled indicates whether to not retry sending batches in case of export failure.
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
Enabled bool `json:"enabled,omitempty"`
// InitialInterval the time to wait after the first failure before retrying.
InitialInterval time.Duration `json:"initial_interval,omitempty" yaml:"initial_interval,omitempty"`
InitialInterval time.Duration `json:"initial_interval,omitempty"`
// RandomizationFactor is a random factor used to calculate next backoffs
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
RandomizationFactor string `json:"randomization_factor,omitempty" yaml:"randomization_factor,omitempty"`
RandomizationFactor string `json:"randomization_factor,omitempty"`
// Multiplier is the value multiplied by the backoff interval bounds
Multiplier string `json:"multiplier,omitempty" yaml:"multiplier,omitempty"`
Multiplier string `json:"multiplier,omitempty"`
// 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 `json:"max_interval,omitempty" yaml:"max_interval,omitempty"`
MaxInterval time.Duration `json:"max_interval,omitempty"`
// 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. If set to 0, the retries are never stopped.
MaxElapsedTime time.Duration `json:"max_elapsed_time,omitempty" yaml:"max_elapsed_time,omitempty"`
MaxElapsedTime time.Duration `json:"max_elapsed_time,omitempty"`
}

// KeepaliveClientConfig exposes the keepalive.ClientParameters to be used by the exporter.
// Refer to the original data-structure for the meaning of each parameter:
// https://godoc.org/google.golang.org/grpc/keepalive#ClientParameters
type KeepaliveClientConfig struct {
Time time.Duration `json:"time,omitempty" yaml:"time,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
PermitWithoutStream bool `json:"permit_without_stream,omitempty" yaml:"permit_without_stream,omitempty"`
Time time.Duration `json:"time,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
PermitWithoutStream bool `json:"permit_without_stream,omitempty"`
}

// ClientConfig defines common settings for a gRPC client configuration.
type GRPCClientConfig struct {
// The target to which the exporter is going to send traces or metrics,
// using the gRPC protocol. The valid syntax is described at
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
Endpoint string `json:"endpoint" yaml:"endpoint"`
Endpoint *string `json:"endpoint"`

// The compression key for supported compression types within collector.
Compression configcompression.Type `json:"compression,omitempty" yaml:"compression,omitempty"`
Compression *configcompression.Type `json:"compression,omitempty"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting TLSClientSetting `json:"tls,omitempty" yaml:"tls,omitempty"`
TLSSetting *TLSClientSetting `json:"tls,omitempty"`

// The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
// (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
Keepalive *KeepaliveClientConfig `json:"keepalive,omitempty" yaml:"keepalive,omitempty"`
Keepalive *KeepaliveClientConfig `json:"keepalive,omitempty"`

// ReadBufferSize for gRPC client. See grpc.WithReadBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithReadBufferSize).
ReadBufferSize int `json:"read_buffer_size,omitempty" yaml:"read_buffer_size,omitempty"`
ReadBufferSize *int `json:"read_buffer_size,omitempty"`

// WriteBufferSize for gRPC gRPC. See grpc.WithWriteBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithWriteBufferSize).
WriteBufferSize int `json:"write_buffer_size,omitempty" yaml:"write_buffer_size,omitempty"`
WriteBufferSize *int `json:"write_buffer_size,omitempty"`

// WaitForReady parameter configures client to wait for ready state before sending data.
// (https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md)
WaitForReady bool `json:"wait_for_ready,omitempty" yaml:"wait_for_ready,omitempty"`
WaitForReady *bool `json:"wait_for_ready,omitempty"`

// The headers associated with gRPC requests.
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
Headers *map[string]string `json:"headers,omitempty"`

// Sets the balancer in grpclb_policy to discover the servers. Default is pick_first.
// https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md
BalancerName string `json:"balancer_name,omitempty" yaml:"balancer_name,omitempty"`
BalancerName *string `json:"balancer_name,omitempty"`

// WithAuthority parameter configures client to rewrite ":authority" header
// (godoc.org/google.golang.org/grpc#WithAuthority)
Authority string `json:"authority,omitempty" yaml:"authority,omitempty"`
Authority *string `json:"authority,omitempty"`

// Auth configuration for outgoing RPCs.
Auth *Authentication `json:"auth,omitempty" yaml:"auth,omitempty"`
Auth *Authentication `json:"auth,omitempty"`
}

// TLSClientSetting contains TLS configurations that are specific to client
// connections in addition to the common configurations. This should be used by
// components configuring TLS client connections.
type TLSClientSetting struct {
// squash ensures fields are correctly decoded in embedded struct.
TLSSetting `json:",inline" yaml:",inline"`
TLSSetting `json:",inline"`

// These are config options specific to client connections.

Expand All @@ -128,13 +128,13 @@ type TLSClientSetting struct {
// (InsecureSkipVerify in the tls Config). Please refer to
// https://godoc.org/crypto/tls#Config for more information.
// (optional, default false)
Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty"`
Insecure bool `json:"insecure,omitempty"`
// InsecureSkipVerify will enable TLS but not verify the certificate.
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty" yaml:"insecure_skip_verify,omitempty"`
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
// ServerName requested by client for virtual hosting.
// This sets the ServerName in the TLSConfig. Please refer to
// https://godoc.org/crypto/tls#Config for more information. (optional)
ServerName string `json:"server_name_override,omitempty" yaml:"server_name_override,omitempty"`
ServerName string `json:"server_name_override,omitempty"`
}

// TLSSetting exposes the common client and server TLS configurations.
Expand All @@ -144,104 +144,104 @@ type TLSSetting struct {
// Path to the CA cert. For a client this verifies the server certificate.
// For a server this verifies client certificates. If empty uses system root CA.
// (optional)
CAFile string `json:"ca_file,omitempty" yaml:"ca_file,omitempty"`
CAFile string `json:"ca_file,omitempty"`

// In memory PEM encoded cert. (optional)
CAPem string `json:"ca_pem,omitempty" yaml:"ca_pem,omitempty"`
CAPem string `json:"ca_pem,omitempty"`

// Path to the TLS cert to use for TLS required connections. (optional)
CertFile string `json:"cert_file,omitempty" yaml:"cert_file,omitempty"`
CertFile string `json:"cert_file,omitempty"`

// In memory PEM encoded TLS cert to use for TLS required connections. (optional)
CertPem string `json:"cert_pem,omitempty" yaml:"cert_pem,omitempty"`
CertPem string `json:"cert_pem,omitempty"`

// Path to the TLS key to use for TLS required connections. (optional)
KeyFile string `json:"key_file,omitempty" yaml:"key_file,omitempty"`
KeyFile string `json:"key_file,omitempty"`

// In memory PEM encoded TLS key to use for TLS required connections. (optional)
KeyPem string `json:"key_pem,omitempty" yaml:"key_pem,omitempty"`
KeyPem string `json:"key_pem,omitempty"`

// MinVersion sets the minimum TLS version that is acceptable.
// If not set, TLS 1.2 will be used. (optional)
MinVersion string `json:"min_version,omitempty" yaml:"min_version,omitempty"`
MinVersion string `json:"min_version,omitempty"`

// MaxVersion sets the maximum TLS version that is acceptable.
// If not set, refer to crypto/tls for defaults. (optional)
MaxVersion string `json:"max_version,omitempty" yaml:"max_version,omitempty"`
MaxVersion string `json:"max_version,omitempty"`

// ReloadInterval specifies the duration after which the certificate will be reloaded
// If not set, it will never be reloaded (optional)
ReloadInterval time.Duration `json:"reload_interval,omitempty" yaml:"reload_interval,omitempty"`
ReloadInterval time.Duration `json:"reload_interval,omitempty"`
}

type Authentication struct {
// AuthenticatorID specifies the name of the extension to use in order to authenticate the incoming data point.
AuthenticatorID string `json:"authenticator,omitempty"`
AuthenticatorID *string `json:"authenticator,omitempty"`
}

// ClientConfig defines settings for creating an HTTP client.
type HTTPClientConfig struct {
// The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Endpoint *string `json:"endpoint,omitempty"`

// ProxyURL setting for the collector
ProxyURL string `json:"proxy_url,omitempty" yaml:"proxy_url,omitempty"`
ProxyURL *string `json:"proxy_url,omitempty"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting TLSClientSetting `json:"tls,omitempty" yaml:"tls,omitempty"`
TLSSetting *TLSClientSetting `json:"tls,omitempty"`

// ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize.
ReadBufferSize int `json:"read_buffer_size,omitempty" yaml:"read_buffer_size,omitempty"`
ReadBufferSize *int `json:"read_buffer_size,omitempty"`

// WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize.
WriteBufferSize int `json:"write_buffer_size,omitempty" yaml:"write_buffer_size,omitempty"`
WriteBufferSize *int `json:"write_buffer_size,omitempty"`

// Timeout parameter configures `http.Client.Timeout`.
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Timeout *time.Duration `json:"timeout,omitempty"`

// Additional headers attached to each HTTP request sent by the client.
// Existing header values are overwritten if collision happens.
// Header values are opaque since they may be sensitive.
Headers map[string]configopaque.String `json:"headers,omitempty" yaml:"headers,omitempty"`
Headers *map[string]configopaque.String `json:"headers,omitempty"`

// Auth configuration for outgoing HTTP calls.
Auth Authentication `json:"auth,omitempty" yaml:"auth,omitempty"`
Auth *Authentication `json:"auth,omitempty"`

// The compression key for supported compression types within collector.
Compression configcompression.Type `json:"compression,omitempty" yaml:"compression,omitempty"`
Compression *configcompression.Type `json:"compression,omitempty"`

// MaxIdleConns is used to set a limit to the maximum idle HTTP connections the client can keep open.
// There's an already set value, and we want to override it only if an explicit value provided
MaxIdleConns *int `json:"max_idle_conns,omitempty" yaml:"max_idle_conns,omitempty"`
MaxIdleConns *int `json:"max_idle_conns,omitempty"`

// MaxIdleConnsPerHost is used to set a limit to the maximum idle HTTP connections the host can keep open.
// There's an already set value, and we want to override it only if an explicit value provided
MaxIdleConnsPerHost *int `json:"max_idle_conns_per_host,omitempty" yaml:"max_idle_conns_per_host,omitempty"`
MaxIdleConnsPerHost *int `json:"max_idle_conns_per_host,omitempty"`

// MaxConnsPerHost limits the total number of connections per host, including connections in the dialing,
// active, and idle states.
// There's an already set value, and we want to override it only if an explicit value provided
MaxConnsPerHost *int `json:"max_conns_per_host,omitempty" yaml:"max_conns_per_host,omitempty"`
MaxConnsPerHost *int `json:"max_conns_per_host,omitempty"`

// IdleConnTimeout is the maximum amount of time a connection will remain open before closing itself.
// There's an already set value, and we want to override it only if an explicit value provided
IdleConnTimeout *time.Duration `json:"idle_conn_timeout,omitempty" yaml:"idle_conn_timeout,omitempty"`
IdleConnTimeout *time.Duration `json:"idle_conn_timeout,omitempty"`

// DisableKeepAlives, if true, disables HTTP keep-alives and will only use the connection to the server
// for a single HTTP request.
//
// WARNING: enabling this option can result in significant overhead establishing a new HTTP(S)
// connection for every request. Before enabling this option please consider whether changes
// to idle connection settings can achieve your goal.
DisableKeepAlives bool `json:"disable_keep_alives,omitempty" yaml:"disable_keep_alives,omitempty"`
DisableKeepAlives *bool `json:"disable_keep_alives,omitempty"`

// This is needed in case you run into
// https://github.com/golang/go/issues/59690
// https://github.com/golang/go/issues/36026
// HTTP2ReadIdleTimeout if the connection has been idle for the configured value send a ping frame for health check
// 0s means no health check will be performed.
HTTP2ReadIdleTimeout time.Duration `json:"http2_read_idle_timeout,omitempty" yaml:"http2_read_idle_timeout,omitempty"`
HTTP2ReadIdleTimeout *time.Duration `json:"http2_read_idle_timeout,omitempty"`
// HTTP2PingTimeout if there's no response to the ping within the configured value, the connection will be closed.
// If not set or set to 0, it defaults to 15s.
HTTP2PingTimeout time.Duration `json:"http2_ping_timeout,omitempty" yaml:"http2_ping_timeout,omitempty"`
HTTP2PingTimeout *time.Duration `json:"http2_ping_timeout,omitempty"`
}
51 changes: 25 additions & 26 deletions api/telemetry/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
package v1alpha1

import (
"time"

corev1 "k8s.io/api/core/v1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -86,56 +83,58 @@ type BearerAuthConfig struct {

// OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
type OTLPGRPC struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
TimeoutSettings `json:",inline" yaml:",inline"`
GRPCClientConfig `json:",inline" yaml:",inline"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
TimeoutSettings `json:",inline"`
GRPCClientConfig `json:",inline"`
}

type OTLPHTTP struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
HTTPClientConfig `json:",inline" yaml:",inline"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
HTTPClientConfig `json:",inline"`
}

type Fluentforward struct {
TCPClientSettings `json:",inline" yaml:",inline"` // squash ensures fields are correctly decoded in embedded struct.
TCPClientSettings `json:",inline"`

// RequireAck enables the acknowledgement feature.
RequireAck bool `json:"require_ack,omitempty" yaml:"require_ack,omitempty"`
RequireAck *bool `json:"require_ack,omitempty"`

// The Fluent tag parameter used for routing
Tag string `json:"tag,omitempty" yaml:"tag,omitempty"`
Tag *string `json:"tag,omitempty"`

// CompressGzip enables gzip compression for the payload.
CompressGzip bool `json:"compress_gzip,omitempty" yaml:"compress_gzip,omitempty"`
CompressGzip *bool `json:"compress_gzip,omitempty"`

// DefaultLabelsEnabled is a map of default attributes to be added to each log record.
DefaultLabelsEnabled map[string]bool `json:"default_labels_enabled,omitempty" yaml:"default_labels_enabled,omitempty"`
DefaultLabelsEnabled *map[string]bool `json:"default_labels_enabled,omitempty"`

QueueConfig QueueSettings `json:"sending_queue,omitempty" yaml:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty" yaml:"retry_on_failure,omitempty"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`

Kubernetes *KubernetesMetadata `json:"kubernetes_metadata,omitempty" yaml:"kubernetes_metadata,omitempty"`
Kubernetes *KubernetesMetadata `json:"kubernetes_metadata,omitempty"`
}

type KubernetesMetadata struct {
Key string `json:"key" yaml:"key,omitempty"`
IncludePodLabels bool `json:"include_pod_labels" yaml:"include_pod_labels,omitempty"`
Key string `json:"key"`
IncludePodLabels bool `json:"include_pod_labels"`
}

type TCPClientSettings struct {
// The target endpoint URI to send data to (e.g.: some.url:24224).
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
Endpoint *string `json:"endpoint,omitempty"`

// +kubebuilder:validation:Format=duration

// Connection Timeout parameter configures `net.Dialer`.
ConnectionTimeout time.Duration `json:"connection_timeout,omitempty" yaml:"connection_timeout,omitempty"`
ConnectionTimeout *string `json:"connection_timeout,omitempty"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting TLSClientSetting `json:"tls,omitempty" yaml:"tls,omitempty"`
TLSSetting *TLSClientSetting `json:"tls,omitempty"`

// SharedKey is used for authorization with the server that knows it.
SharedKey string `json:"shared_key,omitempty" yaml:"shared_key,omitempty"`
SharedKey *string `json:"shared_key,omitempty"`
}

// OutputStatus defines the observed state of Output
Expand All @@ -151,15 +150,15 @@ type Output struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec OutputSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
Spec OutputSpec `json:"spec,omitempty"`
Status OutputStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// OutputList contains a list of Output
type OutputList struct {
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Output `json:"items"`
}
Expand Down
Loading
Loading