本文整理汇总了Python中metrology.Metrology类的典型用法代码示例。如果您正苦于以下问题:Python Metrology类的具体用法?Python Metrology怎么用?Python Metrology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Metrology类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, application, reporter=None, **kwargs):
self.application = application
self.request = Metrology.meter('request')
self.request_time = Metrology.timer('request_time')
# Start reporter
if reporter:
reporter.start()
开发者ID:cyberdelia,项目名称:metrology,代码行数:8,代码来源:wsgi.py
示例2: setUp
def setUp(self):
self.reporter = GraphiteReporter('localhost', 3333)
Metrology.meter('meter').mark()
Metrology.counter('counter').increment()
Metrology.timer('timer').update(1.5)
Metrology.utilization_timer('utimer').update(1.5)
Metrology.histogram('histogram').update(1.5)
开发者ID:Motoma,项目名称:metrology,代码行数:8,代码来源:test_graphite.py
示例3: __init__
def __init__(self, notificationDao):
self.notificationDao = notificationDao
self.signal_timer = Metrology.timer('zenactiond.signals')
self.notification_timer = Metrology.timer('zenactiond.notifications')
# set by the constructor of queueConsumer
self.queueConsumer = None
self.schema = getUtility(IQueueSchema)
self.queue = self.schema.getQueue("$Signals")
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:10,代码来源:zenactiond.py
示例4: test_send_batch
def test_send_batch(self, mock):
self.reporter = GraphiteReporter("localhost", 3334, pickle=True, batch_size=2)
Metrology.meter("meter").mark()
Metrology.counter("counter").increment()
Metrology.timer("timer").update(5)
Metrology.utilization_timer("utimer").update(5)
Metrology.histogram("histogram").update(5)
self.reporter.write()
self.assertTrue(mock.sendall.assert_called())
self.assertEqual(25, len(mock.sendall.call_args_list))
self.reporter.stop()
开发者ID:zkplatlab,项目名称:metrology,代码行数:12,代码来源:test_graphite_pickle.py
示例5: register_metrics_on_worklist
def register_metrics_on_worklist(worklist):
metricNames = {x[0] for x in registry}
for metricName, priority in _gauge_priority_map.iteritems():
if metricName not in metricNames:
gauge = PriorityListLengthGauge(worklist, priority)
Metrology.gauge(metricName, gauge)
# Original metric name
if "zenhub.workList" not in metricNames:
gauge = WorklistLengthGauge(worklist)
Metrology.gauge("zenhub.workList", gauge)
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:12,代码来源:worklist.py
示例6: test_send_batch
def test_send_batch(self, mock):
self.reporter = GraphiteReporter('localhost', 3333, batch_size=2)
Metrology.meter('meter').mark()
Metrology.counter('counter').increment()
Metrology.timer('timer').update(5)
Metrology.utilization_timer('utimer').update(5)
Metrology.histogram('histogram').update(5)
self.reporter.write()
self.assertTrue(mock.send.assert_called())
self.assertEqual(25, len(mock.sendall.call_args_list))
self.reporter.stop()
开发者ID:kevineder,项目名称:metrology,代码行数:12,代码来源:test_graphite.py
示例7: __init__
def __init__(self, single=False ):
"""
Initalizer
@param single: collect from a single device?
@type single: boolean
"""
PBDaemon.__init__(self)
# FIXME: cleanup --force option #2660
self.options.force = True
self.start = None
self.startat = None
self.rrdStats = DaemonStats()
self.single = single
if self.options.device:
self.single = True
self.modelerCycleInterval = self.options.cycletime
# get the minutes and convert to fraction of a day
self.collage = float( self.options.collage ) / 1440.0
self.pendingNewClients = False
self.clients = []
self.finished = []
self.devicegen = None
self.counters = collections.Counter()
self.configFilter = None
self.configLoaded = False
# Make sendEvent() available to plugins
zope.component.provideUtility(self, IEventService)
# Delay start for between 10 and 60 seconds when run as a daemon.
self.started = False
self.startDelay = 0
self.immediate = 1
if self.options.daemon or self.options.cycle:
if self.options.now:
self.log.debug('option "now" specified, starting immediately.')
else:
# self.startDelay = randint(10, 60) * 60
self.startDelay = randint(10, 60) * 1
self.immediate = 0
self.log.info('option "now" not specified, waiting %s seconds to start.' %
self.startDelay)
else:
self.log.debug("Run in foreground, starting immediately.")
# ZEN-26637
self.collectorLoopIteration = 0
self.mainLoopGotDeviceList = False
self._modeledDevicesMetric = Metrology.meter("zenmodeler.modeledDevices")
self._failuresMetric = Metrology.counter("zenmodeler.failures")
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:53,代码来源:zenmodeler.py
示例8: setUp
def setUp(self):
self.reporter = GangliaReporter("Group Name", "localhost", 8649)
Metrology.meter('meter').mark()
Metrology.counter('counter').increment()
Metrology.timer('timer').update(5)
Metrology.utilization_timer('utimer').update(5)
开发者ID:cyberdelia,项目名称:metrology,代码行数:7,代码来源:test_ganglia.py
示例9: setUp
def setUp(self):
self.reporter = LibratoReporter("<email>", "<token>")
Metrology.meter('meter').mark()
Metrology.counter('counter').increment()
Metrology.timer('timer').update(1.5)
Metrology.utilization_timer('utimer').update(1.5)
开发者ID:damiendube,项目名称:metrology,代码行数:7,代码来源:test_librato.py
示例10: __init__
def __init__(self,
name,
configId=None,
scheduleIntervalSeconds=None,
taskConfig=None):
super(ConfigurationLoaderTask, self).__init__()
self._fetchConfigTimer = Metrology.timer('collectordaemon.configs')
# Needed for interface
self.name = name
self.configId = configId if configId else name
self.state = TaskStates.STATE_IDLE
self._dataService = zope.component.queryUtility(IDataService)
self._eventService = zope.component.queryUtility(IEventService)
if taskConfig is None:
raise TypeError("taskConfig cannot be None")
self._prefs = taskConfig
self.interval = self._prefs.configCycleInterval * 60
self.options = self._prefs.options
self._daemon = zope.component.getUtility(ICollector)
self._daemon.heartbeatTimeout = self.options.heartbeatTimeout
log.debug("Heartbeat timeout set to %ds", self._daemon.heartbeatTimeout)
frameworkFactory = zope.component.queryUtility(IFrameworkFactory, self._frameworkFactoryName)
self._configProxy = frameworkFactory.getConfigurationProxy()
self.devices = []
self.startDelay=0
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:31,代码来源:config.py
示例11: setUp
def setUp(self):
self.output = StringIO()
logging.basicConfig(stream=self.output, level=logging.INFO)
self.reporter = LoggerReporter()
Metrology.meter('meter').mark()
Metrology.counter('counter').increment()
Metrology.timer('timer').update(1.5)
Metrology.utilization_timer('utimer').update(1.5)
开发者ID:Motoma,项目名称:metrology,代码行数:10,代码来源:test_logger.py
示例12: __init__
def __init__(self, options, log):
self.options = options
self.transformers = _load_utilities(ICollectorEventTransformer)
self.log = log
self.discarded_events = 0
# TODO: Do we want to limit the size of the clear event dictionary?
self.clear_events_count = {}
self._initQueues()
self._eventsSent = Metrology.meter("collectordaemon.eventsSent")
self._discardedEvents = Metrology.meter("collectordaemon.discardedEvent")
self._eventTimer = Metrology.timer('collectordaemon.eventTimer')
metricNames = {x[0] for x in registry}
if 'collectordaemon.eventQueue' not in metricNames:
queue = self
class EventQueueGauge(Gauge):
@property
def value(self):
return queue.event_queue_length
Metrology.gauge('collectordaemon.eventQueue', EventQueueGauge())
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:19,代码来源:PBDaemon.py
示例13: __init__
def __init__(self, reactor):
"""Initialize a ZenHubWorker instance."""
ZCmdBase.__init__(self)
self.__reactor = reactor
if self.options.profiling:
self.profiler = ContinuousProfiler('ZenHubWorker', log=self.log)
self.profiler.start()
reactor.addSystemEventTrigger(
'before', 'shutdown', self.profiler.stop,
)
self.instanceId = self.options.workerid
self.current = IDLE
self.currentStart = 0
self.numCalls = Metrology.meter("zenhub.workerCalls")
self.zem = self.dmd.ZenEventManager
loadPlugins(self.dmd)
serviceFactory = ServiceReferenceFactory(self)
self.__registry = HubServiceRegistry(self.dmd, serviceFactory)
# Configure/initialize the ZenHub client
creds = UsernamePassword(
self.options.hubusername, self.options.hubpassword,
)
endpointDescriptor = "tcp:{host}:{port}".format(
host=self.options.hubhost, port=self.options.hubport,
)
endpoint = clientFromString(reactor, endpointDescriptor)
self.__client = ZenHubClient(reactor, endpoint, creds, self, 10.0)
# Setup Metric Reporting
self.log.debug("Creating async MetricReporter")
self._metric_manager = MetricManager(
daemon_tags={
'zenoss_daemon': 'zenhub_worker_%s' % self.options.workerid,
'zenoss_monitor': self.options.monitor,
'internal': True,
},
)
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:43,代码来源:zenhubworker.py
示例14: __init__
def __init__(self, dmd):
self.dmd = dmd
self._manager = Manager(self.dmd)
self._pipes = (
EventPluginPipe(
self._manager, IPreEventPlugin, 'PreEventPluginPipe'
),
CheckInputPipe(self._manager),
IdentifierPipe(self._manager),
AddDeviceContextAndTagsPipe(self._manager),
TransformAndReidentPipe(
self._manager,
TransformPipe(self._manager),
[
UpdateDeviceContextAndTagsPipe(self._manager),
IdentifierPipe(self._manager),
AddDeviceContextAndTagsPipe(self._manager),
]
),
AssignDefaultEventClassAndTagPipe(self._manager),
FingerprintPipe(self._manager),
SerializeContextPipe(self._manager),
EventPluginPipe(
self._manager, IPostEventPlugin, 'PostEventPluginPipe'
),
ClearClassRefreshPipe(self._manager),
CheckHeartBeatPipe(self._manager)
)
self._pipe_timers = {}
for pipe in self._pipes:
timer_name = pipe.name
self._pipe_timers[timer_name] = Metrology.timer(timer_name)
self.reporter = MetricReporter(prefix='zenoss.zeneventd.')
self.reporter.start()
if not self.SYNC_EVERY_EVENT:
# don't call sync() more often than 1 every 0.5 sec
# helps throughput when receiving events in bursts
self.nextSync = time()
self.syncInterval = 0.5
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:41,代码来源:zeneventd.py
示例15: __init__
def __init__(self, modeling_paused=None):
"""Initializes a ZenHubWorklist object.
If an argument is provided for the modeling_paused parameter,
it should be function that takes no arguments and returns True
to exclude modeling related priorities for job selection.
"""
if modeling_paused is None:
self.__modeling_paused = bool # always False
else:
self.__modeling_paused = modeling_paused
# Associate a list with each priority
self.__worklists = {priority: [] for priority in ZenHubPriority}
# All jobs priority selection
self.__alljobs = _PrioritySelection(_all_priorities)
# No ApplyDataMaps priority selection
self.__noadmjobs = _PrioritySelection(_no_adm_priorities)
# Metric for wait time in worklist
self.__waitTimer = Metrology.timer("zenhub.worklist.wait_time")
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:23,代码来源:worklist.py
示例16: test_health_check
def test_health_check(self):
health = Metrology.health_check('test', HealthCheck)
self.assertTrue(health is not None)
开发者ID:cyberdelia,项目名称:metrology,代码行数:3,代码来源:test_metrology.py
示例17: test_histogram
def test_histogram(self):
self.assertTrue(Metrology.histogram('test') is not None)
开发者ID:cyberdelia,项目名称:metrology,代码行数:2,代码来源:test_metrology.py
示例18: test_utilization_timer
def test_utilization_timer(self):
self.assertTrue(Metrology.utilization_timer('test') is not None)
开发者ID:cyberdelia,项目名称:metrology,代码行数:2,代码来源:test_metrology.py
示例19: test_timer
def test_timer(self):
self.assertTrue(Metrology.timer('test') is not None)
开发者ID:cyberdelia,项目名称:metrology,代码行数:2,代码来源:test_metrology.py
示例20: __init__
def __init__(self, preferences, taskSplitter,
configurationListener=DUMMY_LISTENER,
initializationCallback=None,
stoppingCallback=None):
"""
Constructs a new instance of the CollectorDaemon framework. Normally
only a singleton instance of a CollectorDaemon should exist within a
process, but this is not enforced.
@param preferences: the collector configuration
@type preferences: ICollectorPreferences
@param taskSplitter: the task splitter to use for this collector
@type taskSplitter: ITaskSplitter
@param initializationCallback: a callable that will be executed after
connection to the hub but before
retrieving configuration information
@type initializationCallback: any callable
@param stoppingCallback: a callable that will be executed first during
the stopping process. Exceptions will be
logged but otherwise ignored.
@type stoppingCallback: any callable
"""
# create the configuration first, so we have the collector name
# available before activating the rest of the Daemon class hierarchy.
if not ICollectorPreferences.providedBy(preferences):
raise TypeError("configuration must provide ICollectorPreferences")
else:
self._prefs = ObservableProxy(preferences)
self._prefs.attachAttributeObserver('configCycleInterval', self._rescheduleConfig)
if not ITaskSplitter.providedBy(taskSplitter):
raise TypeError("taskSplitter must provide ITaskSplitter")
else:
self._taskSplitter = taskSplitter
if not IConfigurationListener.providedBy(configurationListener):
raise TypeError(
"configurationListener must provide IConfigurationListener")
self._configListener = ConfigListenerNotifier()
self._configListener.addListener(configurationListener)
self._configListener.addListener(DeviceGuidListener(self))
self._initializationCallback = initializationCallback
self._stoppingCallback = stoppingCallback
# register the various interfaces we provide the rest of the system so
# that collector implementors can easily retrieve a reference back here
# if needed
zope.component.provideUtility(self, ICollector)
zope.component.provideUtility(self, IEventService)
zope.component.provideUtility(self, IDataService)
# register the collector's own preferences object so it may be easily
# retrieved by factories, tasks, etc.
zope.component.provideUtility(self.preferences,
ICollectorPreferences,
self.preferences.collectorName)
super(CollectorDaemon, self).__init__(name=self.preferences.collectorName)
self._statService = StatisticsService()
zope.component.provideUtility(self._statService, IStatisticsService)
if self.options.cycle:
# setup daemon statistics (deprecated names)
self._statService.addStatistic("devices", "GAUGE")
self._statService.addStatistic("dataPoints", "DERIVE")
self._statService.addStatistic("runningTasks", "GAUGE")
self._statService.addStatistic("taskCount", "GAUGE")
self._statService.addStatistic("queuedTasks", "GAUGE")
self._statService.addStatistic("missedRuns", "GAUGE")
# namespace these a bit so they can be used in ZP monitoring.
# prefer these stat names and metrology in future refs
self._dataPointsMetric = Metrology.meter("collectordaemon.dataPoints")
daemon = self
class DeviceGauge(Gauge):
@property
def value(self):
return len(daemon._devices)
Metrology.gauge('collectordaemon.devices', DeviceGauge())
# Scheduler statistics
class RunningTasks(Gauge):
@property
def value(self):
return daemon._scheduler._executor.running
Metrology.gauge('collectordaemon.runningTasks', RunningTasks())
class TaskCount(Gauge):
@property
def value(self):
return daemon._scheduler.taskCount
Metrology.gauge('collectordaemon.taskCount', TaskCount())
class QueuedTasks(Gauge):
@property
def value(self):
return daemon._scheduler._executor.queued
Metrology.gauge('collectordaemon.queuedTasks', QueuedTasks())
class MissedRuns(Gauge):
#.........这里部分代码省略.........
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:101,代码来源:daemon.py
注:本文中的metrology.Metrology类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论