Skip to content

Commit

Permalink
chore: reach parity with upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <bence.csati@axoflow.com>
  • Loading branch information
csatib02 committed Dec 3, 2024
1 parent cbe91ca commit df7ad28
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'

- name: Build
run: go build -v ./...
Expand Down
6 changes: 4 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

// TCPClientSettings defines common settings for a TCP client.
type TCPClientSettings struct {
// The target endpoint URI to send data to (e.g.: some.url:24224).
Endpoint string `mapstructure:"endpoint"`

// Connection Timeout parameter configures `net.Dialer`.
ConnectionTimeout time.Duration `mapstructure:"connection_timeout"`

// TLSSetting struct exposes TLS client configuration.
TLSSetting configtls.ClientConfig `mapstructure:"tls"`
// ClientConfig struct exposes TLS client configuration.
ClientConfig configtls.ClientConfig `mapstructure:"tls"`

// SharedKey is used for authorization with the server that knows it.
SharedKey string `mapstructure:"shared_key"`
Expand Down Expand Up @@ -78,6 +79,7 @@ type KubernetesMetadata struct {

var _ component.Config = (*Config)(nil)

// Validate checks if the configuration is valid
func (config *Config) Validate() error {
if err := config.QueueConfig.Validate(); err != nil {
return fmt.Errorf("queue settings has invalid configuration: %w", err)
Expand Down
38 changes: 19 additions & 19 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,38 @@ func TestLoadConfigNewExporter(t *testing.T) {
TCPClientSettings: TCPClientSettings{
Endpoint: validEndpoint,
ConnectionTimeout: time.Second * 30,
TLSSetting: configtls.ClientConfig{
Insecure: false,
InsecureSkipVerify: true,
ClientConfig: configtls.ClientConfig{
Insecure: true,
InsecureSkipVerify: false,
Config: configtls.Config{
CAFile: "ca.crt",
CertFile: "client.crt",
KeyFile: "client.key",
CAFile: "",
CertFile: "",
KeyFile: "",
},
},
SharedKey: "otelcol-dev",
SharedKey: "",
},
RequireAck: true,
Tag: "nginx",
CompressGzip: true,
RequireAck: false,
Tag: "tag",
CompressGzip: false,
DefaultLabelsEnabled: map[string]bool{
"time": true,
"exporter": false,
"job": false,
"instance": false,
"exporter": true,
"job": true,
"instance": true,
},
BackOffConfig: configretry.BackOffConfig{
Enabled: true,
InitialInterval: 10 * time.Second,
MaxInterval: 1 * time.Minute,
MaxElapsedTime: 10 * time.Minute,
InitialInterval: 5 * time.Second,
MaxInterval: 30 * time.Second,
MaxElapsedTime: 5 * time.Minute,
RandomizationFactor: backoff.DefaultRandomizationFactor,
Multiplier: backoff.DefaultMultiplier,
},
QueueConfig: exporterhelper.QueueConfig{
Enabled: true,
NumConsumers: 2,
QueueSize: 10,
NumConsumers: 10,
QueueSize: 1000,
},
},
},
Expand All @@ -81,7 +81,7 @@ func TestLoadConfigNewExporter(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
4 changes: 2 additions & 2 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func newExporter(config *Config, settings component.TelemetrySettings) *fluentfo
}
}

func (f *fluentforwardExporter) start(_ context.Context, host component.Host) error {
func (f *fluentforwardExporter) start(ctx context.Context, host component.Host) error {
connOptions := fclient.ConnectionOptions{
RequireAck: f.config.RequireAck,
}

tlsConfig, err := f.config.TLSSetting.LoadTLSConfig()
tlsConfig, err := f.config.ClientConfig.LoadTLSConfig(ctx)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

package fluentforwardexporter // import "github.com/r0mdau/fluentforwardexporter"

import (
"context"
"testing"
Expand Down
4 changes: 2 additions & 2 deletions factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func createDefaultConfig() component.Config {
TCPClientSettings: TCPClientSettings{
Endpoint: "localhost:24224",
ConnectionTimeout: time.Second * 30,
TLSSetting: configtls.ClientConfig{
ClientConfig: configtls.ClientConfig{
Insecure: true,
InsecureSkipVerify: false,
Config: configtls.Config{
Expand All @@ -58,7 +58,7 @@ func createDefaultConfig() component.Config {
}
}

func createLogsExporter(ctx context.Context, set exporter.CreateSettings, config component.Config) (exporter.Logs, error) {
func createLogsExporter(ctx context.Context, set exporter.Settings, config component.Config) (exporter.Logs, error) {
exporterConfig := config.(*Config)
exp := newExporter(exporterConfig, set.TelemetrySettings)

Expand Down
2 changes: 1 addition & 1 deletion factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestNewExporterFullConfig(t *testing.T) {
TCPClientSettings: TCPClientSettings{
Endpoint: validEndpoint,
ConnectionTimeout: time.Second * 30,
TLSSetting: configtls.TLSClientSetting{
ClientConfig: configtls.ClientConfig{
Insecure: true,
InsecureSkipVerify: false,
},
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.23.2

require (
github.com/IBM/fluent-forward-go v0.2.3-0.20240418091724-720f8df4306a
github.com/IBM/fluent-forward-go v0.2.2
github.com/cenkalti/backoff/v4 v4.3.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.112.0
Expand All @@ -14,17 +14,18 @@ require (
go.opentelemetry.io/collector/confmap v1.18.0
go.opentelemetry.io/collector/exporter v0.112.0
go.opentelemetry.io/collector/pdata v1.18.0
go.opentelemetry.io/otel/metric v1.31.0
go.opentelemetry.io/otel/trace v1.31.0
go.uber.org/zap v1.27.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -47,10 +48,8 @@ require (
go.opentelemetry.io/collector/pdata/pprofile v0.112.0 // indirect
go.opentelemetry.io/collector/pipeline v0.112.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.26.0 // indirect
Expand Down
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
Expand All @@ -19,8 +19,6 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
Expand Down Expand Up @@ -150,6 +148,7 @@ golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ status:
development: [logs]
distributions: [contrib]
codeowners:
active: [r0mdau]
active: [r0mdau]
2 changes: 1 addition & 1 deletion testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ fluentforward/allsettings:
enabled: true
initial_interval: 10s
max_interval: 60s
max_elapsed_time: 10m
max_elapsed_time: 10m

0 comments on commit df7ad28

Please sign in to comment.