Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行prometheus(python)时CollectorRegistry中的重复时间序列_Python_Spyder_Prometheus - Fatal编程技术网

运行prometheus(python)时CollectorRegistry中的重复时间序列

运行prometheus(python)时CollectorRegistry中的重复时间序列,python,spyder,prometheus,Python,Spyder,Prometheus,我试图遵循客户机python项目的设计。 所以我有以下代码 from prometheus_client import start_http_server, Summary import random import time # Create a metric to track time spent and requests made. REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing req

我试图遵循客户机python项目的设计。 所以我有以下代码

from prometheus_client import start_http_server, Summary
import random
import time

# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

# Decorate function with metric.
@REQUEST_TIME.time()
def process_request(t):
    """A dummy function that takes some time."""
    time.sleep(t)

if __name__ == '__main__':
    # Start up the server to expose the metrics.
    start_http_server(8000)
    # Generate some requests.
    while True:
        process_request(random.random())
我仍在试图理解如何在这里使用普罗米修斯,但我的问题有点不同。 我正在使用蟒蛇,我已经创造了一个蟒蛇环境。在这个环境中,我安装了spyder作为我的IDE。所以我把这个代码放在一个文件中,然后运行它

第一次没有问题(我可以用普罗米修斯做一些监测,但那是另一个故事)。但是,当我想停止此操作时,我按Ctrl-C,程序会按预期退出

但是,如果我再次运行它,则会出现以下错误:

Traceback (most recent call last):

  File "C:\Users\user\Prometheus\firstPro\primer.py", line 13, in <module>
    REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')

  File "C:\Users\user\anaconda3\envs\firstPro\lib\site-packages\prometheus_client\metrics.py", line 121, in __init__
    registry.register(self)

  File "C:\Users\user\anaconda3\envs\firstPro\lib\site-packages\prometheus_client\registry.py", line 31, in register
    duplicates))

ValueError: Duplicated timeseries in CollectorRegistry: {'request_processing_seconds_created', 'request_processing_seconds_sum', 'request_processing_seconds_count', 'request_processing_seconds'}
回溯(最近一次呼叫最后一次):
文件“C:\Users\user\Prometheus\firstPro\primer.py”,第13行,在
请求\u时间=摘要('请求\u处理\u秒','处理请求花费的时间')
文件“C:\Users\user\anaconda3\envs\firstPro\lib\site packages\prometheus\u client\metrics.py”,第121行,在uu init中__
注册表。注册表(self)
文件“C:\Users\user\anaconda3\envs\firstPro\lib\site packages\prometheus\u client\registry.py”,第31行,在寄存器中
副本)
ValueError:CollectorRegistry中重复的时间序列:{'request\u processing\u seconds\u created','request\u processing\u seconds\u sum','request\u processing\u seconds\u count','request\u processing\u seconds'}
我不能再运行python程序了。显然存在“重复的时间序列”,因此上一次运行似乎没有结束

如果我关闭spyder,然后再次打开它,我可以在第一次运行它


有人能帮我了解一下这里发生了什么吗?

您可能在双重注册催收员。