forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
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 debug input operator files (open-telemetr…
…y#32073) Contributes to open-telemetry#32058
- Loading branch information
1 parent
0e370d8
commit 30e26bf
Showing
6 changed files
with
120 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package generate // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/generate" | ||
|
||
import ( | ||
"go.uber.org/zap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper" | ||
) | ||
|
||
const operatorType = "generate_input" | ||
|
||
func init() { | ||
operator.Register(operatorType, func() operator.Builder { return NewConfig("") }) | ||
} | ||
|
||
// NewConfig creates a new generate input config with default values | ||
func NewConfig(operatorID string) *Config { | ||
return &Config{ | ||
InputConfig: helper.NewInputConfig(operatorID, operatorType), | ||
} | ||
} | ||
|
||
// Config is the configuration of a generate input operator. | ||
type Config struct { | ||
helper.InputConfig `mapstructure:",squash"` | ||
Entry entry.Entry `mapstructure:"entry"` | ||
Count int `mapstructure:"count"` | ||
Static bool `mapstructure:"static"` | ||
} | ||
|
||
// Build will build a generate input operator. | ||
func (c *Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) { | ||
inputOperator, err := c.InputConfig.Build(logger) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
c.Entry.Body = recursiveMapInterfaceToMapString(c.Entry.Body) | ||
|
||
return &Input{ | ||
InputOperator: inputOperator, | ||
entry: c.Entry, | ||
count: c.Count, | ||
static: c.Static, | ||
}, 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
File renamed without changes.
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,44 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package stdin // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/stdin" | ||
|
||
import ( | ||
"os" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper" | ||
) | ||
|
||
const operatorType = "stdin" | ||
|
||
func init() { | ||
operator.Register(operatorType, func() operator.Builder { return NewConfig("") }) | ||
} | ||
|
||
// NewConfig creates a new stdin input config with default values | ||
func NewConfig(operatorID string) *Config { | ||
return &Config{ | ||
InputConfig: helper.NewInputConfig(operatorID, operatorType), | ||
} | ||
} | ||
|
||
// Config is the configuration of a stdin input operator. | ||
type Config struct { | ||
helper.InputConfig `mapstructure:",squash"` | ||
} | ||
|
||
// Build will build a stdin input operator. | ||
func (c *Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) { | ||
inputOperator, err := c.InputConfig.Build(logger) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Input{ | ||
InputOperator: inputOperator, | ||
stdin: os.Stdin, | ||
}, 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
File renamed without changes.