Closed jlondonobo closed 4 months ago
All modified and coverable lines are covered by tests :white_check_mark:
:loudspeaker: Thoughts on this report? Let us know!
In https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1714658053546979 a user essentially requested the suppress_instrumentation
function, so I've made it public here.
This PR fixes https://github.com/pydantic/logfire/issues/135 in the sense that those particular urllib3 logs don't get sent to logfire. They are now logged by the fallback handler of LogfireLoggingHandler which logs to stderr by default. After this, I want to add a snippet like the following to the docs showing how to filter those logs if the noise in the console is still annoying:
import logging
import time
from logging import DEBUG, basicConfig, getLogger
from logfire.integrations.logging import LogfireLoggingHandler
logfire_handler = LogfireLoggingHandler()
# Don't write to stderr the urllib3 debug logs created while exporting traces
urllib3_filter = logging.Filter('urllib3')
logfire_handler.fallback.addFilter(lambda record: not urllib3_filter.filter(record))
basicConfig(handlers=[logfire_handler], level=DEBUG)
logger = getLogger(__name__)
for _ in range(1000):
logger.info('log')
time.sleep(0.6)
Thanks @jlondonobo for your help, your changes were pretty much exactly what was needed!
Add support for all OTEL keys for instrument suppression.
This PR adds support for the following keys:
"suppress_instrumentation"
_SUPPRESS_INSTRUMENTATION_KEY