Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Tracer client: 'Settings' object has no attribute 'OPENTRACING_TRACING' #56

Open
bj00rn opened this issue Jun 25, 2019 · 4 comments

Comments

@bj00rn
Copy link

bj00rn commented Jun 25, 2019

Scratching my head over how to use this library with a Tracer client (jaeger) inside my views

Do i need to explicitly set OPENTRACING_TRACING in settings.py?

Getting the following error on startup

AttributeError: 'Settings' object has no attribute 'OPENTRACING_TRACING'

settings.py

# default tracer is opentracing.Tracer(), which does nothing
OPENTRACING_TRACER_CALLABLE = __name__ + '.tracer'

def tracer():
    from jaeger_client import Config
    config = Config(
        config={
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'local_agent': {
                'reporting_host': os.environ.get('JAEGER_HOST', "localhost"),
                'reporting_port': os.environ.get('JAEGER_PORT', 6831),
            },
            'logging': True,
        },
        service_name='-'.join([os.environ.get('JAEGER_SERVICE_NAME', ''), 'api']))

    return config.initialize_tracer()


# default is False
OPENTRACING_TRACE_ALL = True

# default is []
OPENTRACING_TRACED_ATTRIBUTES = ['META']



views.py

from django.conf import settings

tracing = settings.OPENTRACING_TRACING

@tracing.trace(optional_args)
def some_view_func(request):
    ... # do some stuff
@liorco3000
Copy link

Hi i was wondering the same thing,
is there any working example with a client ?

@bj00rn
Copy link
Author

bj00rn commented Jun 26, 2019

Hi i was wondering the same thing,
is there any working example with a client ?

here is another example project i started off from.

still not sure about the OPENTRACING_TRACING part though

@romainr
Copy link

romainr commented Jul 30, 2019

You can print OPENTRACING_TRACER_CALLABLE value, then import the value later in your views.

e.g.

> from settings import OPENTRACING_TRACER_CALLABLE
> print OPENTRACING_TRACER_CALLABLE
opentracing.tracer

then

import opentracing.tracer
opentracing.tracer.active_span.set_tag('tag', '10')

@bj00rn
Copy link
Author

bj00rn commented Aug 29, 2019

@romainr im trying to use the @trace decorator not the tracer itself.

according to docs this would be sufficient in the views file:

from django.conf import settings

tracing = settings.OPENTRACING_TRACING

@tracing.trace(optional_args)
def some_view_func(request):
    ... # do some stuff

however this gives the error

AttributeError: 'Settings' object has no attribute 'OPENTRACING_TRACING'

@bj00rn bj00rn changed the title Usage with Tracer client Usage with Tracer client: 'Settings' object has no attribute 'OPENTRACING_TRACING' Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants