Skip to content

django-opentracing-logger is a django opentracing SDK based on logger which focus on ease to use.

License

Notifications You must be signed in to change notification settings

FingerLiu/django-opentracing-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

opentracing python SDK

0. intro

django-opentracing-logger is a django opentracing SDK based on logger which focus on ease to use.

1. install

# current 0.0.1
pip install django-opentracing-logger

2. config opentracing logger

# settings.py
from django_opentracing_logger.opentracing.tracer import set_log_tracer

# add request middleware
MIDDLEWARE = [
    'django_opentracing_logger.opentracing.middleware.DDTracerMiddleware',
]

# add logger
LOGGING = {
    'filters': {
        'trace_id': {
            '()': 'django_opentracing_logger.opentracing.logging.TraceIDFilter',
        }
    },
    'formatters': {
        # ...,
        'trace': {
            '()': 'pythonjsonlogger.jsonlogger.JsonFormatter',
            'fmt': '%(message)s',
        }
    },
    'handlers': {
        # ...,
        'trace': {
            'level': 'INFO',
            'class': 'django_opentracing_logger.opentracing.logging.TraceHandler',
            'filename': '%s/trace.log' % '/data/logs/trace',
            'backupCount': 10,
            'when': 'D',
            'interval': 1,
            'formatter': 'trace'
        }
    },
    'loggers': {
        'tracer': {'handlers': ['trace'], 'propagate': True, 'level': 'DEBUG'},
    }
}

# init tracer
APM_ENABLE = True 
if APM_ENABLE:
    set_log_tracer("PROJECT_NAME") # TODO replace PROJECT_NAME with your real project name

3. collect

collect logs in /data/logs/trace

4. view

use any viewer which Compatible with opentracing.

About

django-opentracing-logger is a django opentracing SDK based on logger which focus on ease to use.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages