-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate entries in app insights #1214
Comments
Are you perhaps using a databricks notebook to run this? This error usually occurs when you are adding multiple instances of the azure log handler to your logger. |
I also have the exact same issue as @DSilvadev , see image of duplicate entries below which have the same timestamp. This error happens whether I use opencensus library in locally or databricks environment. And I am adding the azure log handler to my logger just once. |
Could you paste a code snippet of how you are using the azure log handler? |
Hi, I also experience the same issue when exporting logs to Azure in a Python Azure Function, also duplicate messages are being logged in app insights:
Also operation id is not being set on the trace message with custom dimensions: Message without custom dimension: I'm new at writing python code so my apologizes with that. |
Try adding: root_logger = logging.getLogger()
for handler in root_logger.handlers[:]:
root_logger.removeHandler(handler) before
in your code to remove duplicate logs. |
@lzchen will try it and let you know the results, thanks. |
Just did some testing, and I can confirm that removing the handlers from the root logger corrected the issue with the duplicate messages for me, also correlation id etc.. works also. Only one downside I have noticed is that in this way, the custom dimensions are overridden, meaning you will lose the default custom properties set by Azure Functions as soon as you specify the custom dimensions. Once again thanks for your quick reply, really helpful. |
@lzchen here's my code snippet below. The first code block contains classes I defined which I call in the 2nd code block below, so that it can send logs from my entire app to app insights. Logger classes:
Adding AzureAppInsightsLogger to root handler is done here in my main.py. This enables logs from my app to send to app insights:
|
Hi everyone, I'm getting duplicate logs with the exact timestamp in app insights, as the screenshot below shows:
The code I'm using:
I only get one message with the handler std_out_handler and when I sent message to the _logger the message is duplicated.
Any ideas how to solve / reason for this ?
Python version: 3.10
Opencensus version: 1.1.9
Thanks !
The text was updated successfully, but these errors were encountered: