Closed lmolkova closed 9 months ago
Apparently it's common to create metric instruments in webapi controller constructor (check https://msazure.visualstudio.com/One/_search?action=contents&text=CreateCounter%20file%3A*Controller&type=code) leading to memory leaks - counter instances are kept my MeterListener/otel and are never collected.
The lifetime of instruments does not seem to be documented and it given how common erroneous usage is, it should be worth documenting it, and/or making instruments disposable, or CreateCounter to cache instances.
Closing this one - the bug (memory leak) was fixed in the OpenTelemetry and no longer reproduces in 1.6.0+
Apparently it's common to create metric instruments in webapi controller constructor (check https://msazure.visualstudio.com/One/_search?action=contents&text=CreateCounter%20file%3A*Controller&type=code) leading to memory leaks - counter instances are kept my MeterListener/otel and are never collected.
The lifetime of instruments does not seem to be documented and it given how common erroneous usage is, it should be worth documenting it, and/or making instruments disposable, or CreateCounter to cache instances.