mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 11:31:58 +08:00
37 lines
633 B
Go
37 lines
633 B
Go
package analytics
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/SigNoz/signoz/pkg/factory"
|
|
)
|
|
|
|
// This will be set via ldflags at build time.
|
|
var (
|
|
key string = "<unset>"
|
|
)
|
|
|
|
type Config struct {
|
|
Enabled bool `mapstructure:"enabled"`
|
|
Key string `mapstructure:"key"`
|
|
}
|
|
|
|
func NewConfigFactory() factory.ConfigFactory {
|
|
return factory.NewConfigFactory(factory.MustNewName("analytics"), newConfig)
|
|
}
|
|
|
|
func newConfig() factory.Config {
|
|
return Config{
|
|
Enabled: false,
|
|
Key: key,
|
|
}
|
|
}
|
|
|
|
func (c Config) Validate() error {
|
|
if c.Key != key {
|
|
return fmt.Errorf("cannot override key set at build time with key: %s", c.Key)
|
|
}
|
|
|
|
return nil
|
|
}
|