forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filelog.go
59 lines (49 loc) · 2.03 KB
/
filelog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package filelogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver"
import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/receiver"
"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/file"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver/internal/metadata"
)
// NewFactory creates a factory for filelog receiver
func NewFactory() receiver.Factory {
return adapter.NewFactory(ReceiverType{}, metadata.LogsStability)
}
// ReceiverType implements stanza.LogReceiverType
// to create a file tailing receiver
type ReceiverType struct{}
// Type is the receiver type
func (f ReceiverType) Type() component.Type {
return metadata.Type
}
// CreateDefaultConfig creates a config with type and version
func (f ReceiverType) CreateDefaultConfig() component.Config {
return createDefaultConfig()
}
func createDefaultConfig() *FileLogConfig {
return &FileLogConfig{
BaseConfig: adapter.BaseConfig{
Operators: []operator.Config{},
RetryOnFailure: consumerretry.NewDefaultConfig(),
},
InputConfig: *file.NewConfig(),
}
}
// BaseConfig gets the base config from config, for now
func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig {
return cfg.(*FileLogConfig).BaseConfig
}
// FileLogConfig defines configuration for the filelog receiver
type FileLogConfig struct {
InputConfig file.Config `mapstructure:",squash"`
adapter.BaseConfig `mapstructure:",squash"`
}
// InputConfig unmarshals the input operator
func (f ReceiverType) InputConfig(cfg component.Config) operator.Config {
return operator.NewConfig(&cfg.(*FileLogConfig).InputConfig)
}