opentelemetry.io icon indicating copy to clipboard operation
opentelemetry.io copied to clipboard

[.NET] remove the pattern of "using var meterProvider"

Open svrnm opened this issue 1 year ago • 13 comments

It'd be good to get a follow up PR to remove the pattern of "using var meterProvider", and prefer an explicit dispose().. We have a lot of people copying this to helper functions, and accidently causing it to get disposed() when helper method exits!

https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/docs/trace/getting-started-console/Program.cs#L27-L29

Separate PR to not further delay this PR

Originally posted by @cijothomas in https://github.com/open-telemetry/opentelemetry.io/pull/4016#discussion_r1504577727

svrnm avatar Mar 01 '24 10:03 svrnm

aggghhh it makes me sad that people are copy-pasting a using var into a method that immediately goes out of scope, but alas, it makes sense

cartermp avatar Mar 01 '24 22:03 cartermp

aggghhh it makes me sad that people are copy-pasting a using var into a method that immediately goes out of scope, but alas, it makes sense

Sorry that I make you sad, I just copy and pasted what I found, I have no idea about .NET 🤷‍♂️

svrnm avatar Mar 04 '24 09:03 svrnm

Should be partially covered by #4310

reyang avatar Apr 16 '24 18:04 reyang