opencensus-python
opencensus-python copied to clipboard
Add TraceLoggingFilter
Filters are another, flexible way to add contextual information to the logs.
A filter can be attached to both a Logger and a Handler, allowing for more granular control on how to add contextual information to a log record.
E.g., a filter can be attached only to a opencensus export handler. And this will affect all log records emitted to handler, even if you use plain logging.info(...)
instead of logging.getLogger(__name__).info(...)
.
Example:
def configure_logging():
handler = AzureLogHandler(
connection_string=app_insights_conn_str,
sampler=AlwaysOnSampler(),
credential=credential,
)
root = logging.getLogger()
root.addHandler(handler)
handler.addFilter(TraceLoggingFilter())
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
For more information, open the CLA check for this pull request.
Friendly ping? (: