Usage with Tracer client: 'Settings' object has no attribute 'OPENTRACING_TRACING'
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
Hi i was wondering the same thing, is there any working example with a client ?
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
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')
@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'