-
Notifications
You must be signed in to change notification settings - Fork 791
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
An error occurred while writing to logger(s) - Safe handle has been closed #3269
Comments
#2905 same issue I think. |
OK is a workaround for me to change this option to false. I do not really need scopes. I understand this package is not stable so I was very careful to not release to production this and caught it early days. Worth maybe just updating the document on the seperate package page to say DO NOT USE SCOPES 😆 --edit |
The linked issue is not caused by scopes. We are not aware of any issues with scopes. So I can't saw how your issue was solved by disabling scopes. Will investigate more... If you can get a repro - please do share it, as that'd super helpful. |
I am trying to see if I can reproduce it locally. It usually only happens on our test servers. Also the area that the stack trace reports for me as being disposed does not make sense because there is no usings or context of state there ... apart the use of Scope. I think this somehow is related. It back out again on our test servers I hope to not see any more errors for now. |
PS- I did not have ParseStateValues = true; I had it turned off the whole time (default) So this safe handles does not relate to that? Just my opinion I don't know if internally it still tried to access the state even though its set to false. I have checked with it on and off and can see the difference in Elastics with the state KV being save (true) and not being saved (false) I have gone over all out logs and NO local machine ever throws this error. It only looks like our remote machines have some kind of issue here. I don't know if its related to infrastructure/ networking or something specific on the hosted machines. We do get a lot of a Task has been cancelled because of requests ending sooner than we expected due to front end stuff |
From the callstack, the LogProcessor is already disposed (either by the user code if the user is controlling the lifecycle of LoggerProvider, or by the hosting environment - e.g. ASP.NET or ASP.NET Core). I can imagine there are cases where the user has less or even no control over the lifecycle of LoggerProvider, and it'll be better if we can avoid punishing the app by throwing exception from LogProcessor/SDK.
|
We are not doing anything explicitly with the LoggerProviders. In this case we are using NET472 API project with logger factory created and attaching open telemetry to that as per documentation. As mentioned. We get a lot of requests cancelled but the problem here is that random request now just get completely bricked because this error is coming up. OTLP Tracing works fine for us. |
I feel this is something that OpenTelemetry .NET should provide a workaround. I've seen many places where ILogger gets used after the LoggerProvider is disposed. |
I wonder if anybody else is having this issue? It would be amazing to get a fix out for this as I am waiting to turn this on in production. Unfortunately I cant use myget feeds so it would either need me to compile it or have a fix in *beta |
^^ this was incorrect. This is a separate issue! |
@ppumkin #3291 should help to mitigate the issue you're seeing. Meanwhile I hope to get to the bottom of this so we understand whether it was due to the misuse of the DI, or a bug in the underlying framework. Would you be willing to collect more information? Here is my thinking - add a line of code to
|
@reyang I more than happy to help. |
Just wanted to come back and say been running in test across several environments for 4 weeks now. No more issues of this. |
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g.
OpenTelemetry 1.0.2
):-package id="OpenTelemetry" version="1.2.0" targetFramework="net472" />
-package id="OpenTelemetry.Api" version="1.2.0" targetFramework="net472" />
-package id="OpenTelemetry.Contrib.Extensions.AWSXRay" version="1.0.1" targetFramework="net472" />
-package id="OpenTelemetry.Contrib.Instrumentation.AWS" version="1.0.1" targetFramework="net472" />
-package id="OpenTelemetry.Exporter.OpenTelemetryProtocol" version="1.2.0" targetFramework="net472" />
-package id="OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs" version="1.0.0-rc9.2" targetFramework="net472" />
-package id="OpenTelemetry.Instrumentation.AspNet" version="1.0.0-rc9.2" targetFramework="net472" />
-package id="OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" version="1.0.0-rc9.2" targetFramework="net472" />
-package id="OpenTelemetry.Instrumentation.Http" version="1.0.0-rc9.2" targetFramework="net472" />
-package id="OpenTelemetry.Instrumentation.SqlClient" version="1.0.0-rc9.2" targetFramework="net472" />
Runtime version (e.g.
net462
,net48
,netcoreapp3.1
,net6.0
etc. You canfind this information from the
*.csproj
file):NET 4.7.2 - WebAPI - IIS
Symptom
A clear and concise description of what the bug is.
Random requests dying with 500 error and a lot of errors logged with
Funnily enough the errors are coming from the OTLP Logger but verfied in our other APM
An error occurred while writing to logger(s) - Safe handle has been closed
What is the expected behavior?
Nothing.. just works
What is the actual behavior?
ERROR 500 on random requests
Reproduce
Not possible? Very flakey issue
We are using Tracing Exporter BatchExporter for a few months and that is OK
Using the Logs BatchExporter, clearly can see an issue there
Not sure if its a STATE that we are passing in?
We will close this issue if:
projects, so don't point us to such, please.
Additional Context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: