logfire icon indicating copy to clipboard operation
logfire copied to clipboard

Ignore stdlib logs from urllib3

Open alexmojaki opened this issue 1 year ago • 6 comments

https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1713885605381719

We can specifically ignore the message https://logfire-api.pydantic.dev:443 "POST /v1/traces HTTP/1.1" 200 2 (and same for /v1/metrics) so that the user doesn't have to silence all of urllib3 to avoid this noise.

alexmojaki avatar May 06 '24 12:05 alexmojaki

+1 👍

epicwhale avatar May 06 '24 12:05 epicwhale

fyi: when I put this into my fastapi project, I realised the noise is VERY HIGH - almost takes over the entire real estate.. image

epicwhale avatar May 06 '24 17:05 epicwhale

Shouldn't the urllib3 instrumentation respect the contextvars to not infinite loop instrumentation? Are we maybe not propagating them correctly?

adriangb avatar May 07 '24 02:05 adriangb

This is urllib3 using stdlib logging, i.e. this fix would be in the stdlib logging instrumentation. The urllib3 instrumentation is not involved.

But you do bring up a good point. Looking more closely, we use the string suppress_instrumentation, whereas OTEL mostly uses _SUPPRESS_INSTRUMENTATION_KEY = create_key("suppress_instrumentation") which is different.

alexmojaki avatar May 07 '24 12:05 alexmojaki

OTEL currently has a haphazard mix of suppress instrumentation keys. We should probably just set all of them.

adriangb avatar May 07 '24 12:05 adriangb

Well in this case it's about reading the correct key. OTEL conveniently sets it in the right places in BatchSpanProcessor and SimpleSpanProcessor.

alexmojaki avatar May 07 '24 12:05 alexmojaki

Fixed by https://github.com/pydantic/logfire/pull/197

alexmojaki avatar May 31 '24 14:05 alexmojaki