config

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BasePath       = fmt.Sprintf("%s/.loggen", os.Getenv("HOME"))
	ConfigFilename = fmt.Sprintf("%s/config.yaml", BasePath)
)

Functions

func GetLogLineMarshaller added in v1.1.0

func GetLogLineMarshaller[T logLine](config LogConfig) func(T) string

func GetSettingValue

func GetSettingValue(name string) any

func Load

func Load()

func Reset

func Reset() error

func SettingNames

func SettingNames() []string

func UpdateSettingValue

func UpdateSettingValue(name string, value string) error

func ValidArgSettingName

func ValidArgSettingName(cmdName string) func(cmd *cobra.Command, args []string) error

Types

type Config

type Config struct {
	URL           string            `yaml:"url" json:"url" validate:"required"`
	Headers       map[string]string `yaml:"headers" json:"headers"`
	APIKey        string            `yaml:"api_key" json:"api_key" validate:"required"`
	APISecret     string            `yaml:"api_secret" json:"api_secret" validate:"required"`
	Labels        map[string]string `yaml:"labels" json:"labels" validate:"required"`
	Rate          int               `yaml:"rate" json:"rate" validate:"required"`
	Timeout       Duration          `yaml:"timeout" json:"timeout" validate:"required"`
	LogConfig     LogConfig         `yaml:"log_config" json:"log_config" validate:"required"`
	EnableMetrics bool              `yaml:"enable_metrics" json:"enable_metrics"`
	Traces        TracesConfig      `yaml:"traces" json:"traces" validate:"required"`
}

func Get

func Get() *Config

func (*Config) GetHeaders added in v1.1.0

func (cfg *Config) GetHeaders() map[string]string

func (Config) MarshalEasyJSON

func (v Config) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Config) MarshalJSON

func (v Config) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Config) UnmarshalEasyJSON

func (v *Config) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Config) UnmarshalJSON

func (v *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Duration added in v1.1.0

type Duration time.Duration

func (Duration) MarshalJSON added in v1.1.0

func (s Duration) MarshalJSON() ([]byte, error)

func (Duration) MarshalYAML added in v1.1.0

func (s Duration) MarshalYAML() (interface{}, error)

func (Duration) Seconds added in v1.1.0

func (s Duration) Seconds() float64

func (Duration) String added in v1.1.0

func (s Duration) String() string

func (*Duration) UnmarshalJSON added in v1.1.0

func (s *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalYAML added in v1.1.0

func (s *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

type LogConfig

type LogConfig struct {
	Format    string            `yaml:"format" json:"format" validate:"oneof=logfmt json"`
	Structure map[string]string `yaml:"structure" json:"structure" validate:"required"`
}

func (LogConfig) MarshalEasyJSON

func (v LogConfig) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (LogConfig) MarshalJSON

func (v LogConfig) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*LogConfig) UnmarshalEasyJSON

func (v *LogConfig) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*LogConfig) UnmarshalJSON

func (v *LogConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SpanAttributeConfig added in v1.1.0

type SpanAttributeConfig struct {
	Name                string `yaml:"name" json:"name"`
	ValueType           string `yaml:"value_type" json:"value_type" validate:"required"`
	ResolveFake         string `yaml:"resolve_fake" json:"resolve_fake"`
	ResolveFromLogValue string `yaml:"resolve_from_log_value" json:"resolve_from_log_value"`
}

func (SpanAttributeConfig) MarshalEasyJSON added in v1.1.0

func (v SpanAttributeConfig) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SpanAttributeConfig) MarshalJSON added in v1.1.0

func (v SpanAttributeConfig) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SpanAttributeConfig) UnmarshalEasyJSON added in v1.1.0

func (v *SpanAttributeConfig) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SpanAttributeConfig) UnmarshalJSON added in v1.1.0

func (v *SpanAttributeConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SpanStep added in v1.1.0

type SpanStep struct {
	Kind       trace.SpanKind        `yaml:"kind" json:"kind" validate:"required"`
	Name       string                `yaml:"name" json:"name"`
	Duration   Duration              `yaml:"duration" json:"duration"`
	Attributes []SpanAttributeConfig `yaml:"attributes" json:"attributes"`
	Children   []SpanStep            `yaml:"children" json:"children"`
}

func (SpanStep) MarshalEasyJSON added in v1.1.0

func (v SpanStep) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SpanStep) MarshalJSON added in v1.1.0

func (v SpanStep) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SpanStep) UnmarshalEasyJSON added in v1.1.0

func (v *SpanStep) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SpanStep) UnmarshalJSON added in v1.1.0

func (v *SpanStep) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type TracesConfig added in v1.1.0

type TracesConfig struct {
	Enabled  bool                  `yaml:"enabled" json:"enabled"`
	Defaults []attribute.Key       `yaml:"defaults" json:"defaults"`
	Custom   attributeKeyValueList `yaml:"custom" json:"custom"`
	Spans    []SpanStep            `json:"spans" json:"spans"`
}

func (TracesConfig) MarshalEasyJSON added in v1.1.0

func (v TracesConfig) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (TracesConfig) MarshalJSON added in v1.1.0

func (v TracesConfig) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*TracesConfig) UnmarshalEasyJSON added in v1.1.0

func (v *TracesConfig) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*TracesConfig) UnmarshalJSON added in v1.1.0

func (v *TracesConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL