Socket
Socket
Sign inDemoInstall

opencensus-ext-logging

Package Overview
Dependencies
Maintainers
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencensus-ext-logging

OpenCensus logging Integration


Maintainers
4

OpenCensus logging Integration

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opencensus-ext-logging.svg :target: https://pypi.org/project/opencensus-ext-logging/

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

.. code:: python

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

  • OpenCensus Project <https://opencensus.io/>_

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc