forked from souvik-ray/monitoring
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.py
More file actions
40 lines (31 loc) · 1.53 KB
/
Test.py
File metadata and controls
40 lines (31 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'''
Created on Jan 27, 2016
@author: souvik
################## This is just a test class for demonstration purpose only. Remove this class ASAP #############################
'''
from metrics.NullMetrics import NullMetricsFactory
from metrics.ThreadLocalMetrics import ThreadLocalMetricsFactory
from metrics.Metrics import Metrics, Unit
from datetime import datetime
from time import time, sleep
#from time import time
#from socket import socket
if __name__ == '__main__':
#metricsFactory = ThreadLocalMetricsFactory("/tmp/service_log").with_account_id("xxxxxxxxxxxxxxx").with_marketplace_id("IDC1").with_program_name("CinderAPI").with_operation_name("CreateVolume");
metricsFactory = NullMetricsFactory().with_display_metric_to_console(True).with_account_id("xxxxxxxxxxxxxxx").with_marketplace_id("IDC1").with_program_name("CinderAPI").with_operation_name("CreateVolume");
i = 0
while (i<100):
metrics = metricsFactory.create_metrics();
metrics.add_property("RequestId", "q311-r329-r302-jf2j-f92f-if93")
metrics.add_date("Sample_Date_Field", time())
metrics.add_count("Success", 1)
metrics.add_count("Failure", 0)
metrics.add_count("Error", 0)
metrics.add_count("Fault", 0)
metrics.add_count("Retry", 0)
metrics.add_time("DatebaseConnectionTime", 500, Unit.MILLIS)
metrics.add_time("RetryWaitTime", 1, Unit.SECONDS)
sleep(0.01)
metrics.close()
i = i+1
#print datetime().now()