Bottle-OpenTracing
This package enables distributed tracing in Bottle applications via The OpenTracing Project.
It is heavily influenced by the Flask Opentracing implementation.
Installation
Run the following command:
$ pip install Bottle-Opentracing
Usage
This Bottle extension allows for tracing of Bottle apps using the OpenTracing API. All
that it requires is for a BottleTracing tracer to be initialized using an
instance of an OpenTracing tracer. You can either trace all requests to your site, or use function decorators to trace certain individual requests.
Note: optional_args in both cases are any number of attributes (as strings) of bottle.Request that you wish to set as tags on the created span
Initialize
BottleTracing wraps the tracer instance that's supported by opentracing. To create a BottleTracing object, you can either pass in a tracer object directly or a callable that returns the tracer object. For example:
import opentracing
from bottle_opentracing import BottleTracing
opentracing_tracer = ## some OpenTracing tracer implementation
tracing = BottleTracing(opentracing_tracer, ...)
or
import opentracing
from bottle_opentracing import BottleTracing
def initialize_tracer():
...
return opentracing_tracer
tracing = BottleTracing(initialize_tracer, ...)
Trace All Requests
import opentracing
from bottle_opentracing import BottleTracing
app = bottle.app()
opentracing_tracer = ## some OpenTracing tracer implementation
tracing = BottleTracing(opentracing_tracer, True, app, [optional_args])
Trace Individual Requests
import opentracing
from bottle_opentracing import BottleTracing
app = bottle.app()
opentracing_tracer = ## some OpenTracing tracer implementation
tracing = BottleTracing(opentracing_tracer)
@app.get('/some_url')
@tracing.trace(optional_args)
def some_view_func():
...
return some_view
Accessing Spans Manually
In order to access the span for a request, we've provided an method BottleTracing.get_span(request) that returns the span for the request, if it is exists and is not finished. This can be used to log important events to the span, set tags, or create child spans to trace non-RPC events. If no request is passed in, the current request will be used.
Tracing an RPC
If you want to make an RPC and continue an existing trace, you can inject the current span into the RPC. For example, if making an http request, the following code will continue your trace across the wire:
@tracing.trace()
def some_view_func(request):
new_request = some_http_request
current_span = tracing.get_span(request)
text_carrier = {}
opentracing_tracer.inject(span, opentracing.Format.TEXT_MAP, text_carrier)
for k, v in text_carrier.iteritems():
new_request.add_header(k,v)
... # make request
Metadata
Release files for Bottle-OpenTracing 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Bottle-OpenTracing-0.0.5.tar.gz | 6.5 kB | Without provenance | Details for Bottle-OpenTracing-0.0.5.tar.gz |
Release files / Bottle-OpenTracing-0.0.5.tar.gz
| Download URL | Bottle-OpenTracing-0.0.5.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd5782fb5db46efc98ca7461e31e4596d52a2fde50023a0bdb71bb1d9614583c
|
|
BLAKE2b-256 checksum How to use checksums |
40f1406b4f5765fb50b23d37aa1ef03956665c00e9955177c787daac61a91446
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for Bottle-OpenTracing 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.