opentelemetry-dotnet-instrumentation
opentelemetry-dotnet-instrumentation copied to clipboard
Dump all spans in the failing tests
What
Got a new idea that we can reuse our own solution to improve tests debugging. Currently we filter out all spans that we are interested in asserting on. If there are errors (flackyness) we just lose the information.
I propose we dump all spans from the mock collector to the output if the test fails.
Temporary workaround to investigate tests: enable the console exporter, on failure we dump the stdout anyway.
Moved to next milestone as we have a workaround. I will try to solve this when working on https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/915
I want to create to create API that could be used in tests more-or-less like:
public async Task SubmitTraces()
{
using var collector = new MockSpanCollector();
collector.Expect(attributes: new[] { K = "otel.library.name", V = "OpenTelemetry.SqlClient" });
await RunTestApplication(collector, arguments: $"{_sqlServerFixture.Password} {_sqlServerFixture.Port}", enableClrProfiler: !IsCoreClr());
}
If it fails it would dump:
- missing expectations
- expectation met
- additional spans
For pure bytecode instrumentations like GraphQL, we could set the collector in "strict mode" which would fail if there are any additional spans (all expectations should be specified).