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

[receiver/collectd] Move to use HTTPServerSettings with collectdreceiver #28812

Merged
merged 12 commits into from
Oct 31, 2023
Prev Previous commit
Next Next commit
bring back timeout field
  • Loading branch information
atoulme committed Oct 31, 2023
commit 52d9c3f5189d8ee2224d27f50e7c74efdb15fd0c
10 changes: 5 additions & 5 deletions receiver/collectdreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ package collectdreceiver // import "github.com/open-telemetry/opentelemetry-coll
import (
"fmt"
"strings"
"time"

"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

// Config defines configuration for Collectd receiver.
type Config struct {
confighttp.HTTPServerSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
Encoding string `mapstructure:"encoding"`
AttributesPrefix string `mapstructure:"attributes_prefix"`
confighttp.HTTPServerSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
Timeout time.Duration `mapstructure:"timeout"`
Encoding string `mapstructure:"encoding"`
AttributesPrefix string `mapstructure:"attributes_prefix"`
}

func (c *Config) Validate() error {
Expand Down
3 changes: 1 addition & 2 deletions receiver/collectdreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/exporter/exporterhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/collectdreceiver/internal/metadata"
)
Expand All @@ -37,7 +36,7 @@ func TestLoadConfig(t *testing.T) {
HTTPServerSettings: confighttp.HTTPServerSettings{
Endpoint: "localhost:12345",
},
TimeoutSettings: exporterhelper.TimeoutSettings{Timeout: 50 * time.Second},
Timeout: 50 * time.Second,
AttributesPrefix: "dap_",
Encoding: "command",
},
Expand Down
5 changes: 1 addition & 4 deletions receiver/collectdreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/collectdreceiver/internal/metadata"
Expand All @@ -35,9 +34,7 @@ func createDefaultConfig() component.Config {
HTTPServerSettings: confighttp.HTTPServerSettings{
Endpoint: defaultBindEndpoint,
},
TimeoutSettings: exporterhelper.TimeoutSettings{
Timeout: 30 * time.Second,
},
Timeout: 30 * time.Second,
Encoding: defaultEncodingFormat,
}
}
Expand Down
4 changes: 2 additions & 2 deletions receiver/collectdreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (cdr *collectdReceiver) Start(_ context.Context, host component.Host) error
if err != nil {
return err
}
cdr.server.ReadTimeout = cdr.config.TimeoutSettings.Timeout
cdr.server.WriteTimeout = cdr.config.TimeoutSettings.Timeout
cdr.server.ReadTimeout = cdr.config.Timeout
cdr.server.WriteTimeout = cdr.config.Timeout
cdr.obsrecv, err = receiverhelper.NewObsReport(receiverhelper.ObsReportSettings{
ReceiverID: cdr.createSettings.ID,
Transport: "http",
Expand Down