Skip to main content

flask jaeger

Project description

目的

方便flask app链路追踪集成

flask-opentracing的不同之处:

flask-opentracing只支持视图前后进行trace,此插件支持任何地方trace

初始化

app = Flask(__name__)
app.config['SERVICE_NAME'] = "test_flask_jaeger"
app.config['JAEGER_HOST'] = '192.168.0.220'
tracer = FlaskJaeger(app)

打log

方式1

@tracer.log_decorator(trace_info={"route": "root api"})

方式2

    tracer.trace_info(func_name=<your func name>, info={"trace_info": "测试测试"})

跨多个请求的时候

例如:

requ1返回一个jaeger_trace_id为123321 requ2返回一个jaeger_trace_id为456654

但是requ1和requ2都是hello_a() function下发出来的,那么就不会形成一个堆栈,解决方法:

response = requests.post("http://127.0.0.1:5000/", json={CUSTOM_TRACE_ID: trace_id})
jaeger_trace_id = response.headers.get(JAEGER_TRACE_ID)
print(jaeger_trace_id) 
response = requests.post("http://127.0.0.1:5000/more", json={CUSTOM_TRACE_ID: trace_id}, headers={JAEGER_TRACE_ID: jaeger_trace_id}) # 使用上一个请求返回的jaeger_trace_id
print(response.headers.get(JAEGER_TRACE_ID))

可以看到,这两个请求返回的jaeger_trace_id都是一样的。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_jaeger-1.0.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

flask_jaeger-1.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file flask_jaeger-1.0.1.tar.gz.

File metadata

  • Download URL: flask_jaeger-1.0.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.2

File hashes

Hashes for flask_jaeger-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0d593801a2c1c6a239e0442d6cb324d9753920fcf5ce91cb3f7f5e566e49926d
MD5 645b68bcb84868672b6d325614c9d46f
BLAKE2b-256 b8dc48480a43ab4afdf75a29466bfa71e0c50848ce5ea867a4969105e7c31fc9

See more details on using hashes here.

File details

Details for the file flask_jaeger-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: flask_jaeger-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.2

File hashes

Hashes for flask_jaeger-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ef9408d50ecf90387a918caf2def6d56053ed3b2e8fb90cff8f96898ba2a72b
MD5 d4816217cb0f79e5d8eb6b19894f5daa
BLAKE2b-256 4f68c2cb3bf884f6c090957d0781fbd56d269f4fb5722949520c87b35e46845a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page