pip_services3_aws.count package

Submodules

Module contents

class pip_services3_aws.count.CloudWatchCounters

Bases: pip_services3_components.count.CachedCounters.CachedCounters, pip_services3_commons.refer.IReferenceable.IReferenceable, pip_services3_commons.run.IOpenable.IOpenable

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 connection

  • *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials

See Counter, CachedCounters, CompositeLogger

Example:

counters = CloudWatchCounters()
counters.config(ConfigParams.from_tuples(
    "connection.region", "us-east-1",
    "connection.access_id", "XXXXXXXXXXX",
    "connection.access_key", "XXXXXXXXXXX"
))

counters.set_references(References.from_tuples(
    Descriptor("pip-services", "logger", "console", "default", "1.0"),
    ConsoleLogger()
))

counters.open("123")

counters.increment("mycomponent.mymethod.calls")
timing = counters.begin_timing("mycomponent.mymethod.exec_time")

try:
    ...
except Exception as e
    timing.end_timing(e)


counters.dump();
close(correlation_id: Optional[str])

Closes component and frees used resources.

Parameters

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

configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)

Configures component by passing configuration parameters.

Parameters

config – configuration parameters to be set.

is_open() bool

Checks if the component is opened.

Returns

true if the component has been opened and false otherwise.

open(correlation_id: Optional[str])

Opens the component.

Parameters

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

set_references(references: pip_services3_commons.refer.IReferences.IReferences)

Sets references to dependent components.

Parameters

references – references to locate the component dependencies.

See IReferences

class pip_services3_aws.count.CloudWatchUnit

Bases: object

Bits = 'Bits'
Bits_Second = 'Bits/Second'
Bytes = 'Bytes'
Bytes_Second = 'Bytes/Second'
Count = 'Count'
Count_Second = 'Count/Second'
Gigabits = 'Gigabits'
Gigabits_Second = 'Gigabits/Second'
Gigabytes = 'Gigabytes'
Gigabytes_Second = 'Gigabytes/Second'
Kilobits = 'Kilobits'
Kilobits_Second = 'Kilobits/Second'
Kilobytes = 'Kilobytes'
Kilobytes_Second = 'Kilobytes/Second'
Megabits = 'Megabits'
Megabits_Second = 'Megabits/Second'
Megabytes = 'Megabytes'
Megabytes_Second = 'Megabytes/Second'
Microseconds = 'Microseconds'
Milliseconds = 'Milliseconds'
Nothing = 'None'
Percent = 'Percent'
Seconds = 'Seconds'
Terabits = 'Terabits'
Terabits_Second = 'Terabits/Second'
Terabytes = 'Terabytes'
Terabytes_Second = 'Terabytes/Second'