zoukankan      html  css  js  c++  java
  • python 版本 jaeger-client 导入失败 jaeger-client-python

    环境为:

    OS: ubuntu18.04

    Python: 3.6

    问题原因:

    尝试使用 jaeger-client-python,官方给出的示例(https://github.com/jaegertracing/jaeger-client-python ReadMe文件中所述),出现了下面错误

    Traceback (most recent call last):
      File "jaeger.py", line 3, in <module>
        from jaeger_client import Config
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/__init__.py", line 27, in <module>
        from .config import Config  # noqa
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/config.py", line 26, in <module>
        from .reporter import (
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/reporter.py", line 32, in <module>
        from jaeger_client.thrift_gen.agent import Agent
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/thrift_gen/agent/Agent.py", line 13, in <module>
        from .ttypes import *
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/thrift_gen/agent/ttypes.py", line 12, in <module>
        import jaeger.ttypes
      File "/mnt/d/code/doc2/13_jaeger/jaeger.py", line 3, in <module>
        from jaeger_client import Config
    ImportError: cannot import name 'Config'  

    经过查找发现是在 thrift 生成的文件中导入包出错

    解决方案:重新打包 .whl 安装包

    step1:下载 jaeger-client-python 源码

    step2:修改代码如下

    文件1:./jaeger_client/thrift_gen/agent/ttypes.py 中,找到

    import jaeger.ttypes
    

    修改为:

    from jaeger_client.thrift_gen.jaeger import ttypes as jaeger_ttypes

    文件2:./jaeger_client/thrift_gen/agent/Agent.py 中,找到

    ...
      thrift_spec = (
        None, # 0
        (1, TType.STRUCT, 'batch', (jaeger.ttypes.Batch, jaeger.ttypes.Batch.thrift_spec), None, ), # 1
      )
    ...
    
          if fid == 1:
            if ftype == TType.STRUCT:
              self.batch = jaeger.ttypes.Batch()
              self.batch.read(iprot)
            else:
    ...
    

    修改其中的 jaeger.ttypes 为 jaeger_ttypes

    step3:在代码根目录下执行编译 

    python3 setup.py sdist bdist_wheel

    完成后,生成的文件在 ./dist 下面,有 .whl 和 tgz 两种格式

  • 相关阅读:
    LeetCode.1(两数之和)
    LeetCode.56(合并区间)
    c++ 数字与字符串的相互转换
    软件工程作业-面向对象方法学
    linux终端下解决you need to be root to perform this command
    vue中 v-bind 与 v-model的区别
    vue的核心:虚拟DOM 和 diff 算法
    弱实体集的必要性、属性随笔
    Ubuntu 18.04下Intel SGX应用程序程序开发——获得OCALL调用的返回值
    Ubuntu 18.04 INTEL SGX 修改案例打印Hello Enclave
  • 原文地址:https://www.cnblogs.com/newguy/p/11804998.html
Copyright © 2011-2022 走看看