Skip to content

Commit

Permalink
Prepare upgrade to 0.68.0 (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme authored Jan 3, 2023
1 parent a8c9fed commit 2a42c1f
Show file tree
Hide file tree
Showing 68 changed files with 1,262 additions and 2,221 deletions.
286 changes: 142 additions & 144 deletions go.mod

Large diffs are not rendered by default.

602 changes: 296 additions & 306 deletions go.sum

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/tcplogreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/loggingexporter"
"go.opentelemetry.io/collector/exporter/otlpexporter"
"go.opentelemetry.io/collector/exporter/otlphttpexporter"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/extension/ballastextension"
"go.opentelemetry.io/collector/extension/zpagesextension"
"go.opentelemetry.io/collector/otelcol"
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/processor/batchprocessor"
"go.opentelemetry.io/collector/processor/memorylimiterprocessor"
"go.opentelemetry.io/collector/receiver"
Expand All @@ -97,7 +98,7 @@ import (
"github.com/signalfx/splunk-otel-collector/receiver/smartagentreceiver"
)

func Get() (component.Factories, error) {
func Get() (otelcol.Factories, error) {
var errs []error
extensions, err := extension.MakeFactoryMap(
ecsobserver.NewFactory(),
Expand Down Expand Up @@ -173,7 +174,7 @@ func Get() (component.Factories, error) {
errs = append(errs, err)
}

processors, err := component.MakeProcessorFactoryMap(
processors, err := processor.MakeFactoryMap(
attributesprocessor.NewFactory(),
batchprocessor.NewFactory(),
filterprocessor.NewFactory(),
Expand All @@ -196,7 +197,7 @@ func Get() (component.Factories, error) {
errs = append(errs, err)
}

factories := component.Factories{
factories := otelcol.Factories{
Extensions: extensions,
Receivers: receivers,
Processors: processors,
Expand Down
2 changes: 1 addition & 1 deletion internal/confmapprovider/discovery/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (c *Config) Load(configDPath string) error {

// toServiceConfig renders the loaded Config content
// suitable for use as a Collector configuration
func (c Config) toServiceConfig() map[string]any {
func (c *Config) toServiceConfig() map[string]any {
sc := confmap.New()
service := c.Service.ToStringMap()
sc.Merge(confmap.NewFromStringMap(map[string]any{typeService: service}))
Expand Down
5 changes: 3 additions & 2 deletions internal/confmapprovider/discovery/discoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"go.opentelemetry.io/collector/confmap/converter/expandconverter"
"go.opentelemetry.io/collector/consumer"
otelcolextension "go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/otelcol"
"go.opentelemetry.io/collector/pdata/plog"
otelcolreceiver "go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/otel/metric"
Expand All @@ -53,7 +54,7 @@ const durationEnvVar = "SPLUNK_DISCOVERY_DURATION"
// of the underlying receivers were successfully discovered by the
// discovery receiver from its emitted log records.
type discoverer struct {
factories component.Factories
factories otelcol.Factories
expandConverter confmap.Converter
configs map[string]*Config
extensions map[component.ID]otelcolextension.Extension
Expand Down Expand Up @@ -396,7 +397,7 @@ func (d *discoverer) createReceiverCreateSettings() otelcolreceiver.CreateSettin
}
}

func (c Config) observersForDiscoveryMode() []component.ID {
func (c *Config) observersForDiscoveryMode() []component.ID {
var cids []component.ID
for k := range c.DiscoveryObservers {
cids = append(cids, k)
Expand Down
3 changes: 0 additions & 3 deletions internal/exporter/httpsinkexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import (
"errors"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
)

// Config defines configuration for file exporter.
type Config struct {
config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct

Endpoint string `mapstructure:"endpoint"`
}

Expand Down
33 changes: 17 additions & 16 deletions internal/exporter/httpsinkexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,30 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/otelcol/otelcoltest"
"go.opentelemetry.io/collector/confmap/confmaptest"
)

func TestLoadConfig(t *testing.T) {
factories, err := componenttest.NopFactories()
assert.NoError(t, err)

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := otelcoltest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
configs, err := confmaptest.LoadConf(path.Join(".", "testdata", "config.yaml"))

require.NoError(t, err)
require.NotNil(t, cfg)
require.NotNil(t, configs)

e0 := cfg.Exporters[component.NewID(typeStr)]
assert.Equal(t, e0, factory.CreateDefaultConfig())
e0cm, err := configs.Sub("httpsink")
require.NoError(t, err)
e0 := createDefaultConfig()
require.NoError(t, component.UnmarshalConfig(e0cm, e0))

assert.Equal(t, NewFactory().CreateDefaultConfig(), e0)

e1cm, err := configs.Sub("httpsink/2")
require.NoError(t, err)
e1 := createDefaultConfig()
require.NoError(t, component.UnmarshalConfig(e1cm, e1))

e1 := cfg.Exporters[component.NewIDWithName(typeStr, "2")]
assert.Equal(t, e1,
assert.Equal(t,
&Config{
ExporterSettings: config.NewExporterSettings(component.NewIDWithName(typeStr, "2")),
Endpoint: "localhost:3333",
})
Endpoint: "localhost:3333",
}, e1)
}
4 changes: 1 addition & 3 deletions internal/exporter/httpsinkexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)
Expand All @@ -41,8 +40,7 @@ func NewFactory() exporter.Factory {

func createDefaultConfig() component.Config {
return &Config{
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
Endpoint: defaultEndpoint,
Endpoint: defaultEndpoint,
}
}

Expand Down
20 changes: 3 additions & 17 deletions internal/exporter/httpsinkexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
receivers:
nop:

processors:
nop:

exporters:
httpsink:
httpsink/2:
endpoint: localhost:3333

service:
pipelines:
traces:
receivers: [nop]
processors: [nop]
exporters: [httpsink]
httpsink:
httpsink/2:
endpoint: localhost:3333
10 changes: 4 additions & 6 deletions internal/exporter/pulsarexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/apache/pulsar-client-go/pulsar"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)
Expand All @@ -34,11 +33,10 @@ type Authentication struct {
type Config struct {
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
Authentication Authentication `mapstructure:"auth"`
config.ExporterSettings `mapstructure:",squash"`
Broker string `mapstructure:"broker"`
Topic string `mapstructure:"topic"`
Encoding string `mapstructure:"encoding"`
Producer Producer `mapstructure:"producer"`
Broker string `mapstructure:"broker"`
Topic string `mapstructure:"topic"`
Encoding string `mapstructure:"encoding"`
Producer Producer `mapstructure:"producer"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
exporterhelper.TimeoutSettings `mapstructure:",squash"`
OperationTimeout time.Duration `mapstructure:"operation_timeout"`
Expand Down
14 changes: 6 additions & 8 deletions internal/exporter/pulsarexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
ctx "context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter"
Expand Down Expand Up @@ -60,13 +59,12 @@ type pulsarExporterFactory struct {
func createDefaultConfig() component.Config {

return &Config{
ExporterSettings: config.NewExporterSettings(component.NewID(typeStr)),
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
Broker: defaultBroker,
Topic: defaultMetricsTopic,
Encoding: defaultEncoding,
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
Broker: defaultBroker,
Topic: defaultMetricsTopic,
Encoding: defaultEncoding,
Producer: Producer{
CompressionType: defaultCompressionType,
CompressionLevel: defaultCompressionLevel,
Expand Down
11 changes: 6 additions & 5 deletions internal/receiver/databricksreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/otelcol/otelcoltest"
otelcolreceiver "go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -64,12 +64,13 @@ func TestCreateReceiver(t *testing.T) {
}

func TestParseConfig(t *testing.T) {
factories, err := componenttest.NopFactories()
cfg, err := confmaptest.LoadConf(path.Join("testdata", "config.yaml"))
require.NoError(t, err)
factories.Receivers[typeStr] = NewFactory()
cfg, err := otelcoltest.LoadConfigAndValidate(path.Join("testdata", "config.yaml"), factories)
cm, err := cfg.Sub(component.NewID(typeStr).String())
require.NoError(t, err)
rcfg := createDefaultConfig().(*Config)
err = component.UnmarshalConfig(cm, rcfg)
require.NoError(t, err)
rcfg := cfg.Receivers[component.NewID(typeStr)].(*Config)
assert.Equal(t, "my-instance", rcfg.InstanceName)
assert.Equal(t, "abc123", rcfg.Token)
assert.Equal(t, "https://my.databricks.instance", rcfg.Endpoint)
Expand Down
22 changes: 6 additions & 16 deletions internal/receiver/databricksreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
receivers:
databricks:
instance_name: my-instance
endpoint: https://my.databricks.instance
token: abc123
collection_interval: 10s
max_results: 25
exporters:
nop:
service:
pipelines:
metrics:
receivers:
- databricks
exporters:
- nop
databricks:
instance_name: my-instance
endpoint: https://my.databricks.instance
token: abc123
collection_interval: 10s
max_results: 25
4 changes: 1 addition & 3 deletions internal/receiver/discoveryreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/receiver"
"go.uber.org/multierr"
Expand All @@ -43,8 +42,7 @@ var (
type Config struct {
// Receivers is a mapping of receivers to discover to their receiver creator configs
// and evaluated metrics and application statements, which are used to determine component status.
Receivers map[component.ID]ReceiverEntry `mapstructure:"receivers"`
config.ReceiverSettings `mapstructure:",squash"`
Receivers map[component.ID]ReceiverEntry `mapstructure:"receivers"`
// The configured Observer extensions from which to receive Endpoint events.
// Must implement the observer.Observable interface.
WatchObservers []component.ID `mapstructure:"watch_observers"`
Expand Down
Loading

0 comments on commit 2a42c1f

Please sign in to comment.