count

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Seconds         = "Seconds"
	Microseconds    = "Microseconds"
	Milliseconds    = "Milliseconds"
	Bytes           = "Bytes"
	Kilobytes       = "Kilobytes"
	Megabytes       = "Megabytes"
	Gigabytes       = "Gigabytes"
	Terabytes       = "Terabytes"
	Bits            = "Bits"
	Kilobits        = "Kilobits"
	Megabits        = "Megabits"
	Gigabits        = "Gigabits"
	Terabits        = "Terabits"
	Percent         = "Percent"
	Count           = "Count"
	BytesSecond     = "Bytes/Second"
	KilobytesSecond = "Kilobytes/Second"
	MegabytesSecond = "Megabytes/Second"
	GigabytesSecond = "Gigabytes/Second"
	TerabytesSecond = "Terabytes/Second"
	BitsSecond      = "Bits/Second"
	KilobitsSecond  = "Kilobits/Second"
	MegabitsSecond  = "Megabits/Second"
	GigabitsSecond  = "Gigabits/Second"
	TerabitsSecond  = "Terabits/Second"
	CountSecond     = "Count/Second"
	None            = "None"
)
Constants that determine cloud watch units.

type CloudWatchUnit struct {

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudWatchCounters

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

Performance counters that periodically dumps counters to AWS Cloud Watch Metrics.

### Configuration parameters ###

- connections:

  • discovery_key: (optional) a key to retrieve the connection from IDiscovery
  • region: (optional) AWS region

- credentials:

  • store_key: (optional) a key to retrieve the credentials from ICredentialStore
  • access_id: AWS access/client id
  • access_key: AWS access/client id

- options:

  • interval: interval in milliseconds to save current counters measurements (default: 5 mins)
  • reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)

### References ###

- \*:context-info:\*:\*:1.0 (optional) ContextInfo to detect the context id and specify counters source - \*:discovery:\*:\*:1.0 (optional) IDiscovery services to resolve connections - \*:credential-store:\*:\*:1.0 (optional) Credential stores to resolve credentials

See Counter (in the Pip.Services components package) See CachedCounters (in the Pip.Services components package) See CompositeLogger (in the Pip.Services components package)

### Example ###

counters := NewCloudWatchCounters();
counters.Config(ConfigParams.fromTuples(
    "connection.region", "us-east-1",
    "connection.access_id", "XXXXXXXXXXX",
    "connection.access_key", "XXXXXXXXXXX"
));
counters.SetReferences(NewReferencesFromTuples(
    NewDescriptor("pip-services", "logger", "console", "default", "1.0"),
    NewConsoleLogger()
));

err := counters.Open("123")
    ...

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

    ...

    timing.endTiming();

counters.Dump();

func NewCloudWatchCounters

func NewCloudWatchCounters() *CloudWatchCounters

Creates a new instance of this counters.

func (*CloudWatchCounters) Close

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

Closes component and frees used resources.

  • correlationId (optional) transaction id to trace execution through call chain.
  • Return error or nil no errors occured.

func (*CloudWatchCounters) Configure

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

Configures component by passing configuration parameters.

  • config configuration parameters to be set.

func (*CloudWatchCounters) IsOpen

func (c *CloudWatchCounters) IsOpen() bool

Checks if the component is opened. Returns true if the component has been opened and false otherwise.

func (*CloudWatchCounters) Open

func (c *CloudWatchCounters) Open(correlationId string) error

Opens the component.

  • correlationId (optional) transaction id to trace execution through call chain.
  • Returns error or null no errors occured.

func (*CloudWatchCounters) Save

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

Saves the current counters measurements.

  • counters current counters measurements to be saves.

func (*CloudWatchCounters) SetReferences

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

Sets references to dependent components.

  • references references to locate the component dependencies.

See IReferences (in the Pip.Services commons package)

Jump to

Keyboard shortcuts

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