32 lines
841 B
Go
32 lines
841 B
Go
|
package tracing
|
||
|
|
||
|
import (
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/pkg/tracing"
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/misc"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
subsection = "tracing"
|
||
|
)
|
||
|
|
||
|
// ToTracingConfig extracts tracing config.
|
||
|
func ToTracingConfig(c *config.Config) *tracing.Config {
|
||
|
return &tracing.Config{
|
||
|
Enabled: config.BoolSafe(c.Sub(subsection), "enabled"),
|
||
|
Exporter: tracing.Exporter(config.StringSafe(c.Sub(subsection), "exporter")),
|
||
|
Endpoint: config.StringSafe(c.Sub(subsection), "endpoint"),
|
||
|
Service: "frostfs-node",
|
||
|
InstanceID: getInstanceIDOrDefault(c),
|
||
|
Version: misc.Version,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func getInstanceIDOrDefault(c *config.Config) string {
|
||
|
s := config.StringSlice(c.Sub("node"), "addresses")
|
||
|
if len(s) > 0 {
|
||
|
return s[0]
|
||
|
}
|
||
|
return ""
|
||
|
}
|