Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

OpenCensus logging Integration

Project description

pypi

The logging integration enriches the log records with trace ID, span ID and sampling flag. The following attributes will be added to LogRecord:

  • traceId
  • spanId
  • traceSampled

Note that this only takes effect for loggers created after the integration.

Installation

pip install opencensus-ext-logging

Usage

import logging

from opencensus.trace import config_integration
from opencensus.trace.samplers import AlwaysOnSampler
from opencensus.trace.tracer import Tracer

config_integration.trace_integrations(['logging'])
logging.basicConfig(format='%(asctime)s traceId=%(traceId)s spanId=%(spanId)s %(message)s')
tracer = Tracer(sampler=AlwaysOnSampler())

logger = logging.getLogger(__name__)
logger.warning('Before the span')
with tracer.span(name='hello'):
    logger.warning('In the span')
logger.warning('After the span')

References

Project details


Release history Release notifications

This version

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for opencensus-ext-logging, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size opencensus_ext_logging-0.1.0-py2.py3-none-any.whl (3.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page