Skip to content

Commit

Permalink
[chore][receiver/journald] remove duplicate function NewFactory and p…
Browse files Browse the repository at this point in the history
…ass checkapi (open-telemetry#29005)

**Description:**
Remove duplicate function NewFactory and pass checkapi since we should
only keep one NewFactory.

**Link to tracking Issue:**

open-telemetry#26304

**Testing:**
go run cmd/checkapi/main.go .
go test for journaldreceiver

**Documentation:**

Signed-off-by: sakulali <[email protected]>
  • Loading branch information
sakulali authored and RoryCrispin committed Nov 24, 2023
1 parent 4907b3b commit 02fccbe
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
1 change: 0 additions & 1 deletion cmd/checkapi/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ connector/servicegraphconnector
extension/encoding
extension/observer
processor/servicegraphprocessor
receiver/journaldreceiver
receiver/kafkareceiver
13 changes: 13 additions & 0 deletions receiver/journaldreceiver/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package journaldreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver"

import (
"go.opentelemetry.io/collector/receiver"
)

// NewFactory creates a factory for journald receiver
func NewFactory() receiver.Factory {
return newFactoryAdapter()
}
19 changes: 19 additions & 0 deletions receiver/journaldreceiver/factory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package journaldreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver"

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver/internal/metadata"
)

func TestNewFactory(t *testing.T) {
t.Run("NewFactoryCorrectType", func(t *testing.T) {
factory := NewFactory()
require.EqualValues(t, metadata.Type, factory.Type())
})
}
4 changes: 2 additions & 2 deletions receiver/journaldreceiver/journald.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver/internal/metadata"
)

// NewFactory creates a factory for journald receiver
func NewFactory() receiver.Factory {
// newFactoryAdapter creates a factory for journald receiver
func newFactoryAdapter() receiver.Factory {
return adapter.NewFactory(ReceiverType{}, metadata.LogsStability)
}

Expand Down
4 changes: 2 additions & 2 deletions receiver/journaldreceiver/journald_nonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver/internal/metadata"
)

// NewFactory creates a dummy factory.
func NewFactory() receiver.Factory {
// newFactoryAdapter creates a dummy factory.
func newFactoryAdapter() receiver.Factory {
return receiver.NewFactory(
metadata.Type,
createDefaultConfig,
Expand Down
4 changes: 2 additions & 2 deletions receiver/journaldreceiver/journald_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
func TestLoadConfig(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
factory := NewFactory()
factory := newFactoryAdapter()
cfg := factory.CreateDefaultConfig()

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
Expand All @@ -40,7 +40,7 @@ func TestLoadConfig(t *testing.T) {

func TestInputConfigFailure(t *testing.T) {
sink := new(consumertest.LogsSink)
factory := NewFactory()
factory := newFactoryAdapter()
badCfg := &JournaldConfig{
BaseConfig: adapter.BaseConfig{
Operators: []operator.Config{},
Expand Down

0 comments on commit 02fccbe

Please sign in to comment.