internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(uri string) (wrapper.IConnection, error)

NewConnection opens a connection to mongoDB by using the given uri

func RegisterHealthChecks

func RegisterHealthChecks(mongoUrl string) (netHttp.HandlerFunc, error)

RegisterHealthChecks initializes health checks for the Exporter and returns an http handler func

Types

type Collector

type Collector struct {
	Mongo wrapper.IConnection

	ErrorC chan error
	// contains filtered or unexported fields
}

Collector queries one prometheus metric from mongoDB

func NewCollector

func NewCollector(m Metric, con wrapper.IConnection, errorC chan error) *Collector

NewCollector constructor initializes every descriptor and returns a pointer to the collector

func (*Collector) Collect

func (col *Collector) Collect(ch chan<- prometheus.Metric)

Collect implements required collect function for all prometheus collectors

func (*Collector) Describe

func (col *Collector) Describe(ch chan<- *prometheus.Desc)

Describe must be implemented by a prometheus collector It essentially writes all descriptors to the prometheus desc channel.

func (*Collector) String

func (col *Collector) String() string

type Config

type Config struct {
	Version string
	HTTP    http
	MongoDb mongoDb
	Metrics []Metric
}

Config Root config struct

func ReadConfig

func ReadConfig(data []byte) (Config, error)

ReadConfig Parses given config content

func ReadConfigFile

func ReadConfigFile(configFile string) (Config, error)

ReadConfigFile Initializes a Config instance from a given file path

type Connection

type Connection struct {
	Context context.Context
	// contains filtered or unexported fields
}

Connection to mongoDB

func (Connection) Aggregate

func (con Connection) Aggregate(ctx context.Context, db string, collection string, command string) (wrapper.ICursor, error)

Aggregate executes a given aggregate query on the mongodb

func (Connection) Find

func (con Connection) Find(ctx context.Context, db string, collection string, command string) (wrapper.ICursor, error)

Find executes a given find query on the mongodb

type HttpServer

type HttpServer struct {
	Port int
	// contains filtered or unexported fields
}

HttpServer serves endpoints from the given Config

func NewHttpServer

func NewHttpServer(config Config) *HttpServer

NewHttpServer creates a new instance of the HttpServer

func (*HttpServer) Shutdown

func (s *HttpServer) Shutdown(ctx context.Context) error

Shutdown stops the running server

func (*HttpServer) Start

func (s *HttpServer) Start(wg *sync.WaitGroup)

Starts the HttpServer Returns a WaitGroup which will be released as soon as the server stops

type Metric

type Metric struct {
	Name             string
	Help             string
	Db               string
	Collection       string
	Tags             map[string]string
	Find             string
	Aggregate        string
	MetricsAttribute string            `yaml:"metricsAttribute"`
	TagAttributes    map[string]string `yaml:"tagAttributes"`
}

Metric Collector configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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