Skip to main content

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

opencensus_ext_logging-0.1.0-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file opencensus_ext_logging-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: opencensus_ext_logging-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for opencensus_ext_logging-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 647b7cc0ea9ba56486281234cca299814a1f0e3fe5b541a60e646991cfebd00f
MD5 6933265209399f5cf41f2f97ebff88c6
BLAKE2b-256 55bf4f223f3b73b389e113ab8e2baadabdaa5db34fe8642ade74eb1037f47780

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page