Skip to content

Commit

Permalink
fix(output): make all OTLPgrpc fields available
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
  • Loading branch information
OverOrion committed Feb 2, 2024
1 parent f818b75 commit 2eb1ea1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 44 deletions.
76 changes: 38 additions & 38 deletions api/telemetry/v1alpha1/otlp_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,101 +23,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"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"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"`
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
// NumConsumers is the number of consumers from the queue.
NumConsumers int `json:"num_consumers,omitempty"`
NumConsumers int `json:"num_consumers,omitempty" yaml:"num_consumers,omitempty"`
// QueueSize is the maximum number of batches allowed in queue at a given time.
QueueSize int `json:"queue_size,omitempty"`
QueueSize int `json:"queue_size,omitempty" yaml:"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"` //TODO this is *component.ID at Otel
StorageID string `json:"storage,omitempty" yaml:"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"`
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
// InitialInterval the time to wait after the first failure before retrying.
InitialInterval time.Duration `json:"initial_interval,omitempty"`
InitialInterval time.Duration `json:"initial_interval,omitempty" yaml:"initial_interval,omitempty" `
// RandomizationFactor is a random factor used to calculate next backoffs
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
RandomizationFactor string `json:"randomization_factor,omitempty"`
RandomizationFactor string `json:"randomization_factor,omitempty" yaml:"randomization_factor,omitempty"`
// Multiplier is the value multiplied by the backoff interval bounds
Multiplier string `json:"multiplier,omitempty"`
Multiplier string `json:"multiplier,omitempty" yaml:"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"`
MaxInterval time.Duration `json:"max_interval,omitempty" yaml:"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"`
MaxElapsedTime time.Duration `json:"max_elapsed_time,omitempty" yaml:"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"`
Timeout time.Duration `json:"timeout,omitempty"`
PermitWithoutStream bool `json:"permit_without_stream,omitempty"`
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"`
}

// GRPCClientSettings defines common settings for a gRPC client configuration.
type GRPCClientSettings 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"`
Endpoint string `json:"endpoint" yaml:"endpoint"`

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

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

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

// ReadBufferSize for gRPC client. See grpc.WithReadBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithReadBufferSize).
ReadBufferSize int `json:"read_buffer_size,omitempty"`
ReadBufferSize int `json:"read_buffer_size,omitempty" yaml:"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"`
WriteBufferSize int `json:"write_buffer_size,omitempty" yaml:"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"`
WaitForReady bool `json:"wait_for_ready,omitempty" yaml:"wait_for_ready,omitempty"`

// The headers associated with gRPC requests.
Headers map[string]string `json:"headers,omitempty"`
Headers map[string]string `json:"headers,omitempty" yaml:"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"`
BalancerName string `json:"balancer_name,omitempty" yaml:"balancer_name,omitempty"`

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

// Auth configuration for outgoing RPCs.
Auth string `json:"auth,omitempty"` //TODO this is a reference *configauth.Authentication
Auth string `json:"auth,omitempty" yaml:"auth,omitempty"` //TODO this is a reference *configauth.Authentication
}

// 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"`
TLSSetting `json:",inline" yaml:",inline"`

// These are config options specific to client connections.

Expand All @@ -127,13 +127,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"`
Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty"`
// InsecureSkipVerify will enable TLS but not verify the certificate.
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty"`
InsecureSkipVerify bool `json:"insecure_skip_verify,omitempty" yaml:"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"`
ServerName string `json:"server_name_override,omitempty" yaml:"server_name_override,omitempty"`
}

// TLSSetting exposes the common client and server TLS configurations.
Expand All @@ -143,32 +143,32 @@ 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"`
CAFile string `json:"ca_file,omitempty" yaml:"ca_file,omitempty"`

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

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

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

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

// In memory PEM encoded TLS key to use for TLS required connections. (optional)
KeyPem string `json:"key_pem,omitempty"`
KeyPem string `json:"key_pem,omitempty" yaml:"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"`
MinVersion string `json:"min_version,omitempty" yaml:"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"`
MaxVersion string `json:"max_version,omitempty" yaml:"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"`
ReloadInterval time.Duration `json:"reload_interval,omitempty" yaml:"reload_interval,omitempty"`
}
15 changes: 9 additions & 6 deletions internal/controller/telemetry/otel_conf_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ func (cfgInput *OtelColConfigInput) generateOTLPExporters() map[string]any {

for _, output := range cfgInput.Outputs {
name := fmt.Sprintf("otlp/%s_%s", output.Namespace, output.Name)
result[name] = map[string]any{
"endpoint": output.Spec.OTLP.GRPCClientSettings.Endpoint,
"headers": output.Spec.OTLP.Headers,
"tls": map[string]any{
"insecure": output.Spec.OTLP.TLSSetting.Insecure,
},
otlpGrpcValuesMarshaled, err := yaml.Marshal(output.Spec.OTLP)
if err != nil {
return result
}
var otlpGrpcValues map[string]any
if err := yaml.Unmarshal(otlpGrpcValuesMarshaled, &otlpGrpcValues); err != nil {
return result
}

result[name] = otlpGrpcValues
}

return result
Expand Down

0 comments on commit 2eb1ea1

Please sign in to comment.