census-instrumentation / opencensus-python

A stats collection and distributed tracing framework
Apache License 2.0
668 stars 249 forks source link

Opencensus not working with MLFlow #1023

Open NastasiaSaby opened 3 years ago

NastasiaSaby commented 3 years ago

Describe your environment.

Steps to reproduce.


import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-key>'))
logger.warning('Hello, World!')

import mlflow

What is the expected behavior? MLFlow should be imported.

What is the actual behavior? It's impossible to import mlflow. Its runs forever.

lzchen commented 3 years ago

What is the error message you are getting? How do you know mlflow is not getting imported?

NastasiaSaby commented 3 years ago

The scripts never ends. I have no error message.

lzchen commented 3 years ago

@NastasiaSaby If you remove either logger.addHandler or import mlflow, the script works?

NastasiaSaby commented 3 years ago

@Izchen Thank you for your answers. Yes, it works if I remove either logger.addHandler or import mlflow.

NastasiaSaby commented 3 years ago

I found a workaround, not the cleanest one though.

I import mlflow at the beginning even if it's not useful this way:

import mlflow
import logging

from opencensus.ext.azure.log_exporter import AzureLogHandler

logger = logging.getLogger(__name__)
logger.addHandler(AzureLogHandler(connection_string='InstrumentationKey=<your-key>'))
logger.warning('Hello, World!')

import mlflow
lzchen commented 3 years ago

@NastasiaSaby You have two import lines now?

NastasiaSaby commented 3 years ago

Yes. In reality, the two import lines in my project are in two different files. But you can reproduce the problem by putting all in the same file. @Izchen