opencensus-python: Duplicated messages in Azure Application Insights
Environment
Python 3.9.6 - 64 bit Windows 10 pip 21.3.1 opencensus==0.8.0 opencensus-context==0.1.2 opencensus-ext-azure==1.1.0
Steps to reproduce
I tried running the following code in mutliple places including new venvs that have just the opencensus-ext-azure library
import logging
from opencensus.ext.azure.log_exporter import AzureLogHandler
logger = logging.getLogger(__name__)
handler = AzureLogHandler(connection_string="<My-InstrumentationKey>")
logger.addHandler(handler)
properties = {"custom_dimensions": {"key_1*****": "value_1", "key_2********": "value_2"}}
logger.error("Error 12 : Hello, World!", extra=properties)
What is the expected behavior?
We expect to see 1 message in the traces table in application insights
What is the actual behavior?
Duplicate records with the exact timestamp :
Additional info
I am aware of the issue #901 and i think it’s not the same cause.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 19 (7 by maintainers)
@lzchen adding of the AzureLogHandler multiple times to the root logger was indeed the issue for me (even though I had it wrapped arounf check of streamlit session state, but thats another issue).
Resolved by checking length of logger handlers. Thanks!
@simonsben seen that many time repeat of same telemtry as well