count

package
Version: v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrometheusCounters

type PrometheusCounters struct {
	*ccount.CachedCounters
	// contains filtered or unexported fields
}

PrometheusCounters performance counters that send their metrics to Prometheus service.

The component is normally used in passive mode conjunction with PrometheusMetricsService. Alternatively when connection parameters are set it can push metrics to Prometheus PushGateway.

Configuration parameters:

- connection(s):
  - discovery_key:         (optional) a key to retrieve the connection from connect.idiscovery.html IDiscovery
  - protocol:              connection protocol: http or https
  - host:                  host name or IP address
  - port:                  port number
  - uri:                   resource URI or connection string with all parameters in it
- options:
  - retries:               number of retries (default: 3)
  - connect_timeout:       connection timeout in milliseconds (default: 10 sec)
  - timeout:               invocation timeout in milliseconds (default: 10 sec)

References:

- *:logger:*:*:1.0 (optional) ILogger components to pass log messages - *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements - *:discovery:*:*:1.0 (optional) IDiscovery services to resolve connection

See: RestService See: CommandableHttpService

Example:

    counters = NewPrometheusCounters();
    counters.Configure(cconf.NewConfigParamsFromTuples(
        "connection.protocol", "http",
        "connection.host", "localhost",
        "connection.port", 8080
    ));

	counters.Open("123")

    counters.Increment("mycomponent.mymethod.calls");
    timing := counters.BeginTiming("mycomponent.mymethod.exec_time");
        ...
    timing.EndTiming();

    counters.Dump();

func NewPrometheusCounters

func NewPrometheusCounters() *PrometheusCounters

NewPrometheusCounters is creates a new instance of the performance counters. Returns *PrometheusCounters pointer on new instance

func (*PrometheusCounters) Close

func (c *PrometheusCounters) Close(correlationId string) error

Close method are closes component and frees used resources. Parameters: - correlationId string

(optional) transaction id to trace execution through call chain.

Returns error error or nil, if no errors occured.

func (*PrometheusCounters) Configure

func (c *PrometheusCounters) Configure(config *cconf.ConfigParams)

Configure method are configures component by passing configuration parameters. Parameters: - config *cconf.ConfigParams configuration parameters to be set.

func (*PrometheusCounters) IsOpen

func (c *PrometheusCounters) IsOpen() bool

IsOpen method are checks if the component is opened. Returns true if the component has been opened and false otherwise.

func (*PrometheusCounters) Open

func (c *PrometheusCounters) Open(correlationId string) (err error)

Open method are opens the component. - correlationId string (optional) transaction id to trace execution through call chain. Returns error

error or nil, if no errors occured.

func (*PrometheusCounters) Save

func (c *PrometheusCounters) Save(counters []*ccount.Counter) (err error)

Save method are saves the current counters measurements. - counters []*ccount.Counter

current counters measurements to be saves.

Retruns error error or nil, if no errors occured.

func (*PrometheusCounters) SetReferences

func (c *PrometheusCounters) SetReferences(references cref.IReferences)

SetReferences method are sets references to dependent components. - references cref.IReferences references to locate the component dependencies.

type TPrometheusCounterConverter

type TPrometheusCounterConverter struct {
}
var PrometheusCounterConverter TPrometheusCounterConverter = TPrometheusCounterConverter{}

PrometheusCounterConverter is helper class that converts performance counter values into a response from Prometheus metrics service.

func (*TPrometheusCounterConverter) ToString

func (c *TPrometheusCounterConverter) ToString(counters []*ccount.Counter, source string, instance string) string

ToString method converts the given counters to a string that is returned by Prometheus metrics service.

- counters  a list of counters to convert.
- source    a source (context) name.
- instance  a unique instance name (usually a host name).

Returns string string view of counter

Jump to

Keyboard shortcuts

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