当前位置: 首页>>代码示例>>Python>>正文


Python Gauge.set_to_current_time方法代码示例

本文整理汇总了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))
开发者ID:rossigee,项目名称:backups,代码行数:23,代码来源:prometheus.py

示例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)
开发者ID:colemanja91,项目名称:PyEloqua-Examples,代码行数:32,代码来源:Contacts.LeadType_getOfferDetails.py


注:本文中的prometheus_client.Gauge.set_to_current_time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。