Skip to content
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
5 changes: 5 additions & 0 deletions .chloggen/splunkhec-remove-deprecated-batcher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
change_type: breaking
component: exporter/splunk_hec
note: Remove deprecated `batcher` config field. Use `sending_queue::batch` instead.
issues: [47737]
change_logs: [user, api]
42 changes: 0 additions & 42 deletions exporter/splunkhecexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configoptional"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/exporter/exporterhelper"

translator "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/splunk"
Expand Down Expand Up @@ -56,22 +55,11 @@ type HecTelemetry struct {
ExtraAttributes map[string]string `mapstructure:"extra_attributes"`
}

type DeprecatedBatchConfig struct {
Enabled bool `mapstructure:"enabled"`
FlushTimeout time.Duration `mapstructure:"flush_timeout"`
Sizer exporterhelper.RequestSizerType `mapstructure:"sizer"`
MinSize int64 `mapstructure:"min_size"`
MaxSize int64 `mapstructure:"max_size"`
isSet bool `mapstructure:"-"`
}

// Config defines configuration for Splunk exporter.
type Config struct {
confighttp.ClientConfig `mapstructure:",squash"`
QueueSettings configoptional.Optional[exporterhelper.QueueBatchConfig] `mapstructure:"sending_queue"`
configretry.BackOffConfig `mapstructure:"retry_on_failure"`
// DeprecatedBatcher is the deprecated batcher configuration.
DeprecatedBatcher DeprecatedBatchConfig `mapstructure:"batcher"`

// LogDataEnabled can be used to disable sending logs by the exporter.
LogDataEnabled bool `mapstructure:"log_data_enabled"`
Expand Down Expand Up @@ -142,36 +130,6 @@ type Config struct {
Telemetry HecTelemetry `mapstructure:"telemetry"`
}

func (cfg *Config) Unmarshal(conf *confmap.Conf) error {
if err := conf.Unmarshal(cfg); err != nil {
return err
}
if conf.IsSet("batcher") {
cfg.DeprecatedBatcher.isSet = true
if cfg.QueueSettings.HasValue() && cfg.QueueSettings.Get().Batch.HasValue() {
return errors.New(`deprecated "batcher" cannot be set along with "sending_queue::batch"`)
}
if cfg.DeprecatedBatcher.Enabled {
wasEnabled := cfg.QueueSettings.HasValue()

cfg.QueueSettings.GetOrInsertDefault().Batch = configoptional.Some(exporterhelper.BatchConfig{
FlushTimeout: cfg.DeprecatedBatcher.FlushTimeout,
Sizer: cfg.DeprecatedBatcher.Sizer,
MinSize: cfg.DeprecatedBatcher.MinSize,
MaxSize: cfg.DeprecatedBatcher.MaxSize,
})

// If the deprecated batcher is enabled without a queue, enable blocking queue to replicate the
// behavior of the deprecated batcher.
if !wasEnabled {
cfg.QueueSettings.Get().WaitForResult = true
}
}
}

return nil
}

func (cfg *Config) getURL() (out *url.URL, err error) {
out, err = url.Parse(cfg.Endpoint)
if err != nil {
Expand Down
19 changes: 0 additions & 19 deletions exporter/splunkhecexporter/config.schema.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
$defs:
deprecated_batch_config:
type: object
properties:
enabled:
type: boolean
flush_timeout:
type: string
format: duration
max_size:
type: integer
x-customType: int64
min_size:
type: integer
x-customType: int64
sizer:
$ref: go.opentelemetry.io/collector/exporter/exporterhelper.request_sizer_type
hec_heartbeat:
description: HecHeartbeat defines the heartbeat information for the exporter
type: object
Expand Down Expand Up @@ -46,9 +30,6 @@ $defs:
description: Config defines configuration for Splunk exporter.
type: object
properties:
batcher:
description: DeprecatedBatcher is the deprecated batcher configuration.
$ref: deprecated_batch_config
disable_compression:
description: Disable GZip compression. Defaults to false.
type: boolean
Expand Down
10 changes: 0 additions & 10 deletions exporter/splunkhecexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/splunkhecexporter/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
Expand Down Expand Up @@ -103,7 +102,6 @@ func createTracesExporter(
config component.Config,
) (exporter.Traces, error) {
cfg := config.(*Config)
showDeprecationWarnings(cfg, set.Logger)
c := newTracesClient(set, cfg)

e, err := exporterhelper.NewTraces(
Expand Down Expand Up @@ -140,7 +138,6 @@ func createMetricsExporter(
config component.Config,
) (exporter.Metrics, error) {
cfg := config.(*Config)
showDeprecationWarnings(cfg, set.Logger)
c := newMetricsClient(set, cfg)

e, err := exporterhelper.NewMetrics(
Expand Down Expand Up @@ -177,7 +174,6 @@ func createLogsExporter(
config component.Config,
) (exporter exporter.Logs, err error) {
cfg := config.(*Config)
showDeprecationWarnings(cfg, set.Logger)
c := newLogsClient(set, cfg)

logsExporter, err := exporterhelper.NewLogs(
Expand Down Expand Up @@ -241,9 +237,3 @@ func hecQueueSettings(qs configoptional.Optional[exporterhelper.QueueBatchConfig
qCopy.Batch = configoptional.Some(bCopy)
return configoptional.Some(qCopy)
}

func showDeprecationWarnings(cfg *Config, logger *zap.Logger) {
if cfg.DeprecatedBatcher.isSet {
logger.Warn("The 'batcher' field is deprecated and will be removed in a future release. Use 'sending_queue::batch' instead.")
}
}
Loading