OpenTSDB (through opentsdb-py) dependency for nameko services
Install
pip3 install nameko-opentsdb-py
Install latest version from Git:
pip3 install git+https://github.com/fraglab/nameko-opentsdb-py.git
SharedOpenTSDB - use OpenTSDB with dependency providers.
from nameko.extensions import DependencyProvider
from nameko_opentsdb import SharedOpenTSDB
class ServiceLogicProvider(DependencyProvider):
tsdb = SharedOpenTSDB()
Base class to use OpenTSDB with service, provide access to opentsdb-py functionality.
Extend basic functionality with predefined nameko rpc call metrics:
- Counter('nameko.rpc_call.success', ['method'])
- Counter('nameko.rpc_call.failed', ['method'])
- Gauge('nameko.rpc_call.execute_time_milliseconds', ['method'])
from nameko_opentsdb import OpenTSDB
class Service:
tsdb = OpenTSDB()
from nameko.rpc import rpc
from nameko_opentsdb import OpenTSDB
from opentsdb import Counter
class ProfilesService:
name = 'profiles_service'
tsdb = OpenTSDB(
CREATED=Counter('profiles.created'),
)
@rpc
def create(self):
# Some logic
self.tsdb.CREATED.inc()
return True