OpenTelemetry InMemoryExporter not working deterministically in unit testing #5065
Replies: 1 comment
-
This is not the correct usage of Here is an example that shows how you could use an Here is a test you could refer to: https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs#L99-L130 |
Beta Was this translation helpful? Give feedback.
-
Hi folks,
So I have a piece of code that uses Meter to write some metrics (observablegauege). For obvious reasons, I can't paste the exact code here, but I can provide similar code.
I am writing multiple tests to test this method but all of them follow the same pattern. I am writing a sample test here.
The tests are all non-deterministic and fail sometimes.
I have tried to follow the same pattern from here.
What I have already tried ?
meterProvider.ForceFlush(10)
.meterProvider.ForceFlush()
instead.meterProvider.ShutDown()
at the end of each test.Has anyone had success using InMemoryExporter for unit testing ?
Any help or guide would be much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions