Skip to content

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

@bj00rn

Description

@bj00rn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions