本文整理汇总了Python中prometheus_client.Gauge.set_to_current_time方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.set_to_current_time方法的具体用法?Python Gauge.set_to_current_time怎么用?Python Gauge.set_to_current_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prometheus_client.Gauge
的用法示例。
在下文中一共展示了Gauge.set_to_current_time方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify_success
# 需要导入模块: from prometheus_client import Gauge [as 别名]
# 或者: from prometheus_client.Gauge import set_to_current_time [as 别名]
def notify_success(self, source, hostname, filename, stats):
registry = CollectorRegistry()
s = Summary('backup_size', 'Size of backup file in bytes', registry=registry)
s.observe(stats.size)
s = Summary('backup_dumptime', 'Time taken to dump and compress/encrypt backup in seconds', registry=registry)
s.observe(stats.dumptime)
s = Summary('backup_uploadtime', 'Time taken to upload backup in seconds', registry=registry)
s.observe(stats.uploadtime)
if stats.retained_copies is not None:
g = Gauge('backup_retained_copies', 'Number of retained backups found on destination', registry=registry)
g.set(stats.retained_copies)
g = Gauge('backup_timestamp', 'Time backup completed as seconds-since-the-epoch', registry=registry)
g.set_to_current_time()
def auth_handler(url, method, timeout, headers, data):
return basic_auth_handler(url, method, timeout, headers, data, self.username, self.password)
push_to_gateway(self.url, job=source.id, registry=registry, handler=auth_handler)
logging.info("Pushed metrics for job '%s' to gateway (%s)" % (source.id, self.url))
示例2: str
# 需要导入模块: from prometheus_client import Gauge [as 别名]
# 或者: from prometheus_client.Gauge import set_to_current_time [as 别名]
record['Contacts_LeadType_S_Data_Status1'] = 'CAMPAIGN DETAIL ERROR'
else:
record['Contacts_LeadType_MostRecent_Offer_PrimarySol1'] = thisCampaign['Solution_Code_Family__c']
record['Contacts_LeadType_MostRecent_Offer_ProductSer1'] = thisCampaign['Solution_Code__c']
record['Contacts_LeadType_S_Data_Status1'] = 'CAMPAIGN DETAILS RETREIVED'
if (thisCampaign['Solution_Code_Family__c']==None):
nullCount += 1
logging.info("Records with no Primary Solution: " + str(nullCount))
importDefName = 'Contacts.LeadType - Get Campaign Details ' + str(datetime.now())
cdoInDef = elq.CreateDef(defType='imports', entity='customObjects', cdoID=1269, fields=myFields, defName=importDefName, identifierFieldName='Email_Address1')
logging.info("import definition created: " + cdoInDef['uri'])
postInData = elq.PostSyncData(data = dataOut, defObject=cdoInDef, maxPost=20000)
logging.info("Data successfully imported, job finished: " + str(datetime.now()))
else:
logging.info("No records, job finished")
### Logging for Prometheus
registry = CollectorRegistry()
g = Gauge('job_last_success_unixtime', 'Last time a batch job successfully finished', registry=registry)
g.set_to_current_time()
h = Gauge('job_total_records_success', 'Total number of records successfully processed in last batch', registry=registry)
h.set(len(data))
push_to_gateway(os.environ['PUSHGATEWAY'], job='Contacts.LeadType_getOfferDetails', registry=registry)