Coder Social home page Coder Social logo

zalando-zmon / opentracing-utils Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 8.0 161 KB

Convenient utilities for adding OpenTracing support in your python projects

License: MIT License

Python 100.00%
distributed-tracing flask jaeger library opentracing python requests sqlalchemy utilities

opentracing-utils's People

Contributors

avi-city avatar birne94 avatar dneuhaeuser-zalando avatar hexeberlin avatar hjacobs avatar miry avatar mohabusama avatar mvalkon avatar vetinari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

opentracing-utils's Issues

Add examples

Add examples for how opentracing-utils can be used, for instance with multiple libraries.

Add vendor dependency to README.md

The libraries of the specific vendors (lightstep, instant, jaeger) are not part of dependencies.txt of opentracing-utils and have to be added to the dependencies of the application which is using opentracing-utils (otherwise it will fail, e.g. here https://app.eu.scalyr.com/y/7pqX2nx43k2). It would be nice to mention it in the README in the Usage part.

Logging query parameters in trace_sqlalchemy

Hello,
First of all, thank you for maintaining this project. We are using it and it is very helpful.
Second, I would like to know if it is possible, and is it a good practice, to log the parameters of a SQL query along the query itself (in the trace_sqlalchemy() function in _sqlalchemy.py . It might be very useful for debugging purposes.

The main downside I could think of is the possibility of logging private information of user's input.

I would like to know what do you think about it.

Thanks,
Avi

Add support for scope manager

opentracing==2.0 introduced scope manager API. The tracer is responsible for scope_manager implementation.

The order for detecting parent spans needs to be updated. I suggest one of the following two orders:

Scope manager first

  1. Using opentracing.tracer.active_span managed by the tracer context manager. The new span will be using the
    scope manager.
  2. Using span_extractor.
  3. Detecting span in kwargs.
  4. Using call stack frames inspection.

Explicit first

  1. Using span_extractor.
  2. Detecting span in kwargs.
  3. Using opentracing.tracer.active_span managed by the tracer context manager. The new span will be using the
    scope manager.
  4. Using call stack frames inspection.

as span_extractor and passing spans in kwargs is more explicit.

Nested lib spans

Does this library support spans across multiple libraries?
Like using flask and sqlalchemy within the same trace?

def test_nested_libs(self):
    engine = create_engine('sqlite://')
    User.metadata.create_all(engine)
    session = sessionmaker(bind=engine)()
    app = Flask('test_app')

    @app.route('/')
    def root():
        user = User(name='Tracer', is_active=True)
        session.add(user)
        session.commit()
        return user

    trace_flask(app)
    trace_sqlalchemy()

    with app.app_context():
        print app.test_client().get('/').data

With 1 flask trace with a child sql span

Allow trace decorator to optionally skip tracing based on user defined logic

In certain cases an opentracing-utils user might need to skip @trace spans based on custom logic.

Suggested usage example:

def skip_span_logic(*args, **kwargs):
    if  'something' in kwargs:
        # @trace should not add a new span
        return True

    # @trace should add a new span
    return False


@trace(skip_span=skip_span_logic)
def trace_me(*args, **kwargs):
    # do stuff

This could be helpful in the case of trace_requests(ignore_url_patterns=[...]), since the skip_span func could inform @trace whether to add a span or not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.