census-instrumentation / opencensus-python

A stats collection and distributed tracing framework
Apache License 2.0
667 stars 248 forks source link

Failed to establish a new connection with aplicationinsights.azure.com #1215

Open kevinco26 opened 11 months ago

kevinco26 commented 11 months ago

Describe your environment. Using Opencensus-ext-azure==1.1.3 Python 3.11 Windows machine.

my python code has:

import logging
from opencensus.ext.azure.log_exporter import AzureLogHandler
logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(
    connection_string='<instrumentation key>)
)
logger.exception('Captured an exception.')

This code is running inside my FastAPI backend

When I run my backend api I get the following error repeatedly multiple times Retrying due to transient client side error HTTPSConnectionPool(host='westus-0.in.applicationinsights.azure.com', port=443): Max retries exceeded with url: //v2.1/track (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001E8062DFED0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')).

Also, I don't see anything being logged to application insights.. I used to see it and not anymore.. not sure what changed. Steps to reproduce. Describe exactly how to reproduce the error. Include a code sample if applicable.

What is the expected behavior? Expecting to see logs in azure and expecting to not see Failed to establish connection?

What is the actual behavior? No logs in app insights and connection error emmitted by the handler

lzchen commented 10 months ago

Are you running this in any container of some sort? Perhaps something with your backend api is preventing network calls to be made to the app insights backend