-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
41 lines (30 loc) · 948 Bytes
/
config.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
// Copyright 2024 William Perron. All rights reserved. MIT License.
package sqliteexporter
import (
"errors"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
)
var _ component.Config = (*Config)(nil)
type Config struct {
// Path of the sqlite3 database file. Path is relative to current directory.
// If file does not exist, it will be created by the exporter.
Path string `mapstructure:"path"`
// TODO(wperron) add options for WAL/journal mode, etc.
// TODO(wperron) add option of "hoisted fields" like service name and duration
}
func (cfg *Config) Validate() error {
if cfg.Path == "" {
return errors.New("path must be non-empty")
}
return nil
}
func (cfg *Config) Unmarshal(componentParser *confmap.Conf) error {
if componentParser == nil {
return errors.New("empty config for sqlite exporter")
}
if err := componentParser.Unmarshal(cfg); err != nil {
return err
}
return nil
}