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][receiver/journald] Expose journaldreceiver config on all plat…
…forms (open-telemetry#29754) **Description:** Follow-up to [comment](open-telemetry#29553 (comment)) in open-telemetry#29553 that `journald` also had different configurations according to the GOOS specified at build time. The change moves some types to sources that are built for all OSes while preserving the behavior of the receiver. **Link to tracking Issue:** N/A **Testing:** Added factory tests that validate create and shutdown on all platforms. **Documentation:** N/A
- Loading branch information
Showing
7 changed files
with
145 additions
and
81 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,41 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package journald // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/journald" | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper" | ||
) | ||
|
||
const operatorType = "journald_input" | ||
|
||
// NewConfig creates a new input config with default values | ||
func NewConfig() *Config { | ||
return NewConfigWithID(operatorType) | ||
} | ||
|
||
// NewConfigWithID creates a new input config with default values | ||
func NewConfigWithID(operatorID string) *Config { | ||
return &Config{ | ||
InputConfig: helper.NewInputConfig(operatorID, operatorType), | ||
StartAt: "end", | ||
Priority: "info", | ||
} | ||
} | ||
|
||
// Config is the configuration of a journald input operator | ||
type Config struct { | ||
helper.InputConfig `mapstructure:",squash"` | ||
|
||
Directory *string `mapstructure:"directory,omitempty"` | ||
Files []string `mapstructure:"files,omitempty"` | ||
StartAt string `mapstructure:"start_at,omitempty"` | ||
Units []string `mapstructure:"units,omitempty"` | ||
Priority string `mapstructure:"priority,omitempty"` | ||
Matches []MatchConfig `mapstructure:"matches,omitempty"` | ||
Identifiers []string `mapstructure:"identifiers,omitempty"` | ||
Grep string `mapstructure:"grep,omitempty"` | ||
Dmesg bool `mapstructure:"dmesg,omitempty"` | ||
} | ||
|
||
type MatchConfig map[string]string |
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,19 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !linux | ||
// +build !linux | ||
|
||
package journald // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/journald" | ||
|
||
import ( | ||
"errors" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator" | ||
) | ||
|
||
func (c Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) { | ||
return nil, errors.New("journald input operator is only supported on linux") | ||
} |
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 journaldreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver" | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/component" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/consumerretry" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/journald" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver/internal/metadata" | ||
) | ||
|
||
// createDefaultConfig creates a config with type and version | ||
func createDefaultConfig() component.Config { | ||
return &JournaldConfig{ | ||
BaseConfig: adapter.BaseConfig{ | ||
Operators: []operator.Config{}, | ||
RetryOnFailure: consumerretry.NewDefaultConfig(), | ||
}, | ||
InputConfig: *journald.NewConfig(), | ||
} | ||
} | ||
|
||
// ReceiverType implements adapter.LogReceiverType | ||
// to create a journald receiver | ||
type ReceiverType struct{} | ||
|
||
// Type is the receiver type | ||
func (f ReceiverType) Type() component.Type { | ||
return metadata.Type | ||
} | ||
|
||
// BaseConfig gets the base config from config, for now | ||
func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { | ||
return cfg.(*JournaldConfig).BaseConfig | ||
} | ||
|
||
// JournaldConfig defines configuration for the journald receiver | ||
type JournaldConfig struct { | ||
adapter.BaseConfig `mapstructure:",squash"` | ||
InputConfig journald.Config `mapstructure:",squash"` | ||
} | ||
|
||
// InputConfig unmarshals the input operator | ||
func (f ReceiverType) InputConfig(cfg component.Config) operator.Config { | ||
return operator.NewConfig(&cfg.(*JournaldConfig).InputConfig) | ||
} |
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
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