python prometheus

问题

  1. 对于sanic app,如果不是全局的共享内存,不同worker是分开统计的,导致从接口获取的数据有随机性(时而来源于worker1,时而来源于worker2),多进程模式支持合并输出,需要通过环境变量指定空目录

    • 多进程模式: os.environ["prometheus_multiproc_dir"] = "."
    • sanic_prometheus: start_http_server不支持多进程模式
      • 如果使用main_process_start初始化metric_init, 对于多worker,worker进程设置的metric inc/observe不生效。因为woker进程是主进程的子进程,inc或者observe是在子进程写入的

参考资料

  1. https://prometheus.io/docs/concepts/metric_types/
  2. https://github.com/prometheus/client_python
  3. https://pyk.medium.com/a-guide-to-instrument-sanic-application-part-1-193b3eb403a
posted @   春树&暮云  阅读(166)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示