Skip to content

Commit

Permalink
refactor: remove overwritten fields from api
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Dec 11, 2024
1 parent f0161df commit 41fad59
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 182 deletions.
45 changes: 6 additions & 39 deletions api/telemetry/v1alpha1/otlp_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package v1alpha1
import (
"time"

"github.com/kube-logging/telemetry-controller/internal/controller/telemetry/utils"
"go.opentelemetry.io/collector/config/configcompression"
"go.opentelemetry.io/collector/config/configopaque"
)
Expand All @@ -30,69 +29,37 @@ type TimeoutSettings struct {

// 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"`

// NumConsumers is the number of consumers from the queue.
NumConsumers int `json:"num_consumers,omitempty"`
NumConsumers *int `json:"num_consumers,omitempty"`

// QueueSize is the maximum number of batches allowed in queue at a given time.
// Default value is 100.
QueueSize int `json:"queue_size,omitempty"`

// If Storage is not empty, enables the persistent storage and uses the component specified
// as a storage extension for the persistent queue.
// WARNING: This field will be set by the operator, based on the persistence config
// set on the tenant that the output belongs to.
Storage *string `json:"storage,omitempty"`
}

func (q *QueueSettings) SetDefaultQueueSettings() {
if q == nil {
q = &QueueSettings{}
}
q.Enabled = true
if q.QueueSize == 0 || q.QueueSize < 0 {
q.QueueSize = 100
}
QueueSize *int `json:"queue_size,omitempty"`
}

// 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"`

// 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"`

// 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"`

// Multiplier is the value multiplied by the backoff interval bounds
Multiplier string `json:"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"`
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.
// Default value is 0 to ensure that the data is never discarded.
MaxElapsedTime *time.Duration `json:"max_elapsed_time,omitempty"`
}

func (b *BackOffConfig) SetDefaultBackOffConfig() {
if b == nil {
b = &BackOffConfig{}
}
b.Enabled = true
if b.MaxElapsedTime == nil {
b.MaxElapsedTime = utils.ToPtr(0 * time.Second)
}
}

// 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
Expand Down
12 changes: 6 additions & 6 deletions api/telemetry/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ type BearerAuthConfig struct {
// Configuration for the OTLP gRPC exporter.
// ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
type OTLPGRPC struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
TimeoutSettings `json:",inline"`
GRPCClientConfig `json:",inline"`
}

// Configuration for the OTLP HTTP exporter.
type OTLPHTTP struct {
QueueConfig QueueSettings `json:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
HTTPClientConfig `json:",inline"`
}

Expand All @@ -115,8 +115,8 @@ type Fluentforward struct {
// DefaultLabelsEnabled is a map of default attributes to be added to each log record.
DefaultLabelsEnabled *map[string]bool `json:"default_labels_enabled,omitempty"`

QueueConfig QueueSettings `json:"sending_queue,omitempty"`
RetryConfig BackOffConfig `json:"retry_on_failure,omitempty"`
QueueConfig *QueueSettings `json:"sending_queue,omitempty"`
RetryConfig *BackOffConfig `json:"retry_on_failure,omitempty"`
Kubernetes *KubernetesMetadata `json:"kubernetes_metadata,omitempty"`
}

Expand Down
67 changes: 58 additions & 9 deletions api/telemetry/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ spec:
BackOffConfig defines configuration for retrying batches in case of export failure.
The current supported strategy is exponential backoff.
properties:
enabled:
description: Enabled indicates whether to not retry sending
batches in case of export failure.
type: boolean
initial_interval:
description: InitialInterval the time to wait after the first
failure before retrying.
Expand Down Expand Up @@ -206,10 +202,6 @@ spec:
description: QueueSettings defines configuration for queueing
batches before sending to the consumerSender.
properties:
enabled:
description: Enabled indicates whether to not enqueue batches
before sending to the consumerSender.
type: boolean
num_consumers:
description: NumConsumers is the number of consumers from
the queue.
Expand All @@ -219,13 +211,6 @@ spec:
QueueSize is the maximum number of batches allowed in queue at a given time.
Default value is 100.
type: integer
storage:
description: |-
If Storage is not empty, enables the persistent storage and uses the component specified
as a storage extension for the persistent queue.
WARNING: This field will be set by the operator, based on the persistence config
set on the tenant that the output belongs to.
type: string
type: object
shared_key:
description: SharedKey is used for authorization with the server
Expand Down Expand Up @@ -369,10 +354,6 @@ spec:
BackOffConfig defines configuration for retrying batches in case of export failure.
The current supported strategy is exponential backoff.
properties:
enabled:
description: Enabled indicates whether to not retry sending
batches in case of export failure.
type: boolean
initial_interval:
description: InitialInterval the time to wait after the first
failure before retrying.
Expand Down Expand Up @@ -405,10 +386,6 @@ spec:
description: QueueSettings defines configuration for queueing
batches before sending to the consumerSender.
properties:
enabled:
description: Enabled indicates whether to not enqueue batches
before sending to the consumerSender.
type: boolean
num_consumers:
description: NumConsumers is the number of consumers from
the queue.
Expand All @@ -418,13 +395,6 @@ spec:
QueueSize is the maximum number of batches allowed in queue at a given time.
Default value is 100.
type: integer
storage:
description: |-
If Storage is not empty, enables the persistent storage and uses the component specified
as a storage extension for the persistent queue.
WARNING: This field will be set by the operator, based on the persistence config
set on the tenant that the output belongs to.
type: string
type: object
timeout:
description: |-
Expand Down Expand Up @@ -595,10 +565,6 @@ spec:
BackOffConfig defines configuration for retrying batches in case of export failure.
The current supported strategy is exponential backoff.
properties:
enabled:
description: Enabled indicates whether to not retry sending
batches in case of export failure.
type: boolean
initial_interval:
description: InitialInterval the time to wait after the first
failure before retrying.
Expand Down Expand Up @@ -631,10 +597,6 @@ spec:
description: QueueSettings defines configuration for queueing
batches before sending to the consumerSender.
properties:
enabled:
description: Enabled indicates whether to not enqueue batches
before sending to the consumerSender.
type: boolean
num_consumers:
description: NumConsumers is the number of consumers from
the queue.
Expand All @@ -644,13 +606,6 @@ spec:
QueueSize is the maximum number of batches allowed in queue at a given time.
Default value is 100.
type: integer
storage:
description: |-
If Storage is not empty, enables the persistent storage and uses the component specified
as a storage extension for the persistent queue.
WARNING: This field will be set by the operator, based on the persistence config
set on the tenant that the output belongs to.
type: string
type: object
timeout:
description: Timeout parameter configures `http.Client.Timeout`.
Expand Down
Loading

0 comments on commit 41fad59

Please sign in to comment.