-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore][pkg/stanza] Cleanup noop operator files (#32065)
Contributes to #32058
- Loading branch information
1 parent
15581e4
commit a210907
Showing
4 changed files
with
48 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package noop | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/testutil" | ||
) | ||
|
||
func TestBuildValid(t *testing.T) { | ||
cfg := NewConfigWithID("test") | ||
op, err := cfg.Build(testutil.Logger(t)) | ||
require.NoError(t, err) | ||
require.IsType(t, &Transformer{}, op) | ||
} | ||
|
||
func TestBuildInvalid(t *testing.T) { | ||
cfg := NewConfigWithID("test") | ||
_, err := cfg.Build(nil) | ||
require.Error(t, err) | ||
require.Contains(t, err.Error(), "build context is missing a logger") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package noop // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/transformer/noop" | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper" | ||
) | ||
|
||
// Transformer is an operator that performs no operations on an entry. | ||
type Transformer struct { | ||
helper.TransformerOperator | ||
} | ||
|
||
// Process will forward the entry to the next output without any alterations. | ||
func (t *Transformer) Process(ctx context.Context, entry *entry.Entry) error { | ||
t.Write(ctx, entry) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters