Documentation
¶
Index ¶
Constants ¶
const ( // KeyTypeCounter is the key you should define in the config file for counters. KeyTypeCounter = "Counter" // KeyTypeGauge is the key you should define in the config file for gauges. KeyTypeGauge = "Gauge" // KeyTypeHistogram is the key you should define in the config file for histograms. KeyTypeHistogram = "Histogram" // KeyTypeSummary is the key you should define in the config file for summaries. KeyTypeSummary = "Summary" )
Variables ¶
This section is empty.
Functions ¶
func NewConfigFromFileSystem ¶
func NewConfigFromFileSystem(mainConfigPath string)
NewConfigFromFileSystem will read the config from the file system, you should send the metric config file path and service config file path into metricsPath, servicePath respectively. This function can cause a panic. TODO(denisacostaq@gmail.com): make this a singleton
func NewConfigFromRawString ¶
NewConfigFromRawString allow you to define a `.toml` config in the fly, a raw string with the "config content"
Types ¶
type HistogramOptions ¶
type HistogramOptions struct { Buckets []float64 `json:"buckets"` // ExponentialBuckets is a len three array where: // - The first value is the low bound start bucket. // - The second vale is the growing factor. // - The three one is the buckets amount. ExponentialBuckets []float64 `json:"exponential_buckets"` }
HistogramOptions allows you to define the histogram is buckets.
type Metric ¶
type Metric struct { Name string `json:"name"` URL string `json:"url"` HTTPMethod string `json:"http_method"` Path string `json:"path,omitempty"` Options MetricOptions `json:"options"` HistogramOptions HistogramOptions `json:"histogram_options"` }
Metric keep the metric name as an instance of MetricOptions
type MetricOptions ¶
MetricOptions keep information you about the metric, mostly the type(Counter, Gauge, Summary, and Histogram)
type RootConfig ¶
type RootConfig struct {
Services []Service `json:"services"`
}
RootConfig is the top level node for the config tree, it has a list of metrics and a service from which get this metrics.
func (RootConfig) FilterMetricsByType ¶
func (conf RootConfig) FilterMetricsByType(t string) (metrics []Metric)
FilterMetricsByType will return all the metrics who match whit the 't' parameter.
type Server ¶
type Server struct { // Location should have the ip or URL. Location string `json:"location"` }
Server the server where is running the service
type Service ¶
type Service struct { Name string `json:"name"` // Scheme is http or https Scheme string `json:"scheme"` Port uint16 `json:"port"` BasePath string `json:"basePath"` AuthType string `json:"authType"` TokenHeaderKey string `json:"tokenHeaderKey"` GenTokenEndpoint string `json:"genTokenEndpoint"` TokenKeyFromEndpoint string `json:"tokenKeyFromEndpoint"` Location Server `json:"location"` Metrics []Metric `json:"metrics"` }
Service is a concept to grab information about a running server, for example: where is it http://localhost:1234 (Location + : + Port), what auth kind you need to use? what is the header key you in which you need to send the token, and so on.
func (Service) MetricName ¶
MetricName returns a promehteus style name for the giving metric name.
func (Service) URIToGetMetric ¶
URIToGetMetric build the URI from where you will to get metric information
func (Service) URIToGetToken ¶
URIToGetToken build the URI from where you will to get the token
type ServiceConfigFromFile ¶
type ServiceConfigFromFile struct {
// contains filtered or unexported fields
}
ServiceConfigFromFile get a service config from a file toml
func NewServiceConfigFromFile ¶
func NewServiceConfigFromFile(path string) (conf *ServiceConfigFromFile)
NewServiceConfigFromFile create a config reader configure to read config from the file in path parameter
func (ServiceConfigFromFile) GetConfig ¶
func (srvConf ServiceConfigFromFile) GetConfig() (services []Service, err error)
GetConfig read the file 'filePath' and returns the services config or an error if any
type ServiceConfigReader ¶
type ServiceConfigReader interface { // GetConfig return a service config or an error if any GetConfig() (Service, error) }
ServiceConfigReader is an interface to get a service config from for example: a file, a REST API, a stream and so on...