Documentation
¶
Index ¶
- Constants
- type CloudWatchCounters
- func (c *CloudWatchCounters) Close(ctx context.Context, correlationId string) error
- func (c *CloudWatchCounters) Configure(ctx context.Context, config *cconf.ConfigParams)
- func (c *CloudWatchCounters) IsOpen() bool
- func (c *CloudWatchCounters) Open(ctx context.Context, correlationId string) error
- func (c *CloudWatchCounters) Save(ctx context.Context, counters []ccount.Counter) error
- func (c *CloudWatchCounters) SetReferences(ctx context.Context, references cref.IReferences)
Constants ¶
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 ###
ctx := context.Background() counters := NewCloudWatchCounters() counters.Configure(ctx, config.NewConfigParamsFromTuples( "connection.region", "us-east-1", "connection.access_id", "XXXXXXXXXXX", "connection.access_key", "XXXXXXXXXXX" )) counters.SetReferences(ctx, NewReferencesFromTuples( NewDescriptor("pip-services", "logger", "console", "default", "1.0"), NewConsoleLogger() )) err := counters.Open(ctx, "123") ... counters.Increment(ctx, "mycomponent.mymethod.calls") timing := counters.BeginTiming(ctx, "mycomponent.mymethod.exec_time") ... timing.EndTiming(ctx, err) counters.Dump(ctx)
func NewCloudWatchCounters ¶
func NewCloudWatchCounters() *CloudWatchCounters
Creates a new instance of this counters.
func (*CloudWatchCounters) Close ¶
func (c *CloudWatchCounters) Close(ctx context.Context, correlationId string) error
Closes component and frees used resources.
Parameters: - ctx context.Context operation context. - correlationId (optional) transaction id to trace execution through call chain. - Return error or nil no errors occured.
func (*CloudWatchCounters) Configure ¶
func (c *CloudWatchCounters) Configure(ctx context.Context, 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(ctx context.Context, correlationId string) error
Opens the component.
Parameters: - ctx context.Context operation context. - correlationId (optional) transaction id to trace execution through call chain. - Returns error or null no errors occured.
func (*CloudWatchCounters) Save ¶
Saves the current counters measurements.
Parameters: - ctx context.Context operation context. - counters current counters measurements to be saves.
func (*CloudWatchCounters) SetReferences ¶
func (c *CloudWatchCounters) SetReferences(ctx context.Context, references cref.IReferences)
Sets references to dependent components.
Parameters: - ctx context.Context operation context. - references references to locate the component dependencies.
See IReferences (in the Pip.Services commons package)