opencensus-python icon indicating copy to clipboard operation
opencensus-python copied to clipboard

Add TraceLoggingFilter

Open gukoff opened this issue 2 years ago • 2 comments

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())

gukoff avatar Mar 06 '22 12:03 gukoff

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.

google-cla[bot] avatar Mar 06 '22 12:03 google-cla[bot]

Friendly ping? (:

gukoff avatar May 31 '22 12:05 gukoff