-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
factory.go
63 lines (54 loc) · 1.84 KB
/
factory.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
60
61
62
63
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//go:generate mdatagen metadata.yaml
package filestorage // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage"
import (
"context"
"time"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage/internal/metadata"
)
const (
// use default bbolt value
// https://github.com/etcd-io/bbolt/blob/d5db64bdbfdee1cb410894605f42ffef898f395d/cmd/bbolt/main.go#L1955
defaultMaxTransactionSize = 65536
defaultReboundTriggerThresholdMib = 10
defaultReboundNeededThresholdMib = 100
defaultCompactionInterval = time.Second * 5
)
// NewFactory creates a factory for HostObserver extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
createDefaultConfig,
createExtension,
metadata.ExtensionStability,
)
}
func createDefaultConfig() component.Config {
return &Config{
Directory: getDefaultDirectory(),
Compaction: &CompactionConfig{
Directory: getDefaultDirectory(),
OnStart: false,
OnRebound: false,
MaxTransactionSize: defaultMaxTransactionSize,
ReboundNeededThresholdMiB: defaultReboundNeededThresholdMib,
ReboundTriggerThresholdMiB: defaultReboundTriggerThresholdMib,
CheckInterval: defaultCompactionInterval,
CleanupOnStart: false,
},
Timeout: time.Second,
FSync: false,
CreateDirectory: false,
DirectoryPermissions: "0750",
}
}
func createExtension(
_ context.Context,
params extension.Settings,
cfg component.Config,
) (extension.Extension, error) {
return newLocalFileStorage(params.Logger, cfg.(*Config))
}