简体   繁体   中英

Is there a workaround for using jaeger 4.0.0 with pyinstaller(python3.7)?

Unfortunately, I'm not able to use PyInstaller with jaeger . The problem is some sort of a thrift error between PyInstaller and jaeger . Like discussed here .

Are they any workarounds or fixes?

I have tried it with python 3.6 and the newest jaeger-client. There I get an Errno 2 -> Even I don't even use a Config file

  exec(bytecode, module.__dict__)
  File "jaeger/__init__.py", line 17, in <module>
  File "jaeger/core/configuration.py", line 74, in get_config
FileNotFoundError: [Errno 2] No such file or directory: '/Users/.../PycharmProjects/untitled1/dist/app/jaeger/core/../etc/jaeger.yml'

[6348] Failed to execute script app
from quart import Quart
import uvicorn as uv
import logging
import time
from jaeger_client import Config

app = Quart(__name__)


@app.route('/')
async def root():
    return 'Hello world'

if __name__ == '__main__':
    log_level = logging.DEBUG
    logging.getLogger('').handlers = []
    logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)

    config = Config(
        config={  # usually read from some yaml config
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'logging': True,
        },
        service_name='your-app-name',
        validate=True,
    )
    # this call also sets opentracing.tracer
    tracer = config.initialize_tracer()

    with tracer.start_span('TestSpan') as span:
        span.log_kv({'event': 'test message', 'life': 42})

        with tracer.start_span('ChildSpan', child_of=span) as child_span:
            span.log_kv({'event': 'down below'})

    time.sleep(
        2)  # yield to IOLoop to flush the spans - https://github.com/jaegertracing/jaeger-client-python/issues/50
    tracer.close()  # flush any buffered spans
    uv.run(app)


The script runs as expected -> Spans are created and web server starts. Only in the executable, it does not run. And shows the following error:

  exec(bytecode, module.__dict__)
  File "jaeger/__init__.py", line 17, in <module>
  File "jaeger/core/configuration.py", line 74, in get_config
FileNotFoundError: [Errno 2] No such file or directory: '/Users/.../PycharmProjects/untitled1/dist/app/jaeger/core/../etc/jaeger.yml'

[6348] Failed to execute script app

It seems that PyInstaller can't resolve jaeger_client import. So an easy way is to just edit your spec file and add the whole jaeger_client library as a Tree class:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['script.py'],
             ...)
a.datas += Tree('<python_path>/Lib/site-packages/jaeger_client', prefix='./jaeger_client')
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
...

And generate your executable with pyinstaller script.spec .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM