-
Notifications
You must be signed in to change notification settings - Fork 538
/
config.go
56 lines (44 loc) · 1.43 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package otelutils
import (
"context"
"github.com/flyteorg/flyte/flytestdlib/config"
"github.com/flyteorg/flyte/flytestdlib/logger"
)
//go:generate pflags Config --default-var=defaultConfig
const configSectionKey = "otel"
type ExporterType = string
const (
NoopExporter ExporterType = "noop"
FileExporter ExporterType = "file"
JaegerExporter ExporterType = "jaeger"
)
var (
ConfigSection = config.MustRegisterSection(configSectionKey, defaultConfig)
defaultConfig = &Config{
ExporterType: NoopExporter,
FileConfig: FileConfig{
Filename: "/tmp/trace.txt",
},
JaegerConfig: JaegerConfig{
Endpoint: "http://localhost:14268/api/traces",
},
}
)
type Config struct {
ExporterType ExporterType `json:"type" pflag:",Sets the type of exporter to configure [noop/file/jaeger]."`
FileConfig FileConfig `json:"file" pflag:",Configuration for exporting telemetry traces to a file"`
JaegerConfig JaegerConfig `json:"jaeger" pflag:",Configuration for exporting telemetry traces to a jaeger"`
}
type FileConfig struct {
Filename string `json:"filename" pflag:",Filename to store exported telemetry traces"`
}
type JaegerConfig struct {
Endpoint string `json:"endpoint" pflag:",Endpoint for the jaeger telemtry trace ingestor"`
}
func GetConfig() *Config {
if c, ok := ConfigSection.GetConfig().(*Config); ok {
return c
}
logger.Warnf(context.TODO(), "Failed to retrieve config section [%v].", configSectionKey)
return nil
}