opentelemetry-dotnet-instrumentation icon indicating copy to clipboard operation
opentelemetry-dotnet-instrumentation copied to clipboard

Dump all spans in the failing tests

Open RassK opened this issue 3 years ago • 1 comments
trafficstars

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.

RassK avatar Sep 15 '22 10:09 RassK

Temporary workaround to investigate tests: enable the console exporter, on failure we dump the stdout anyway.

pjanotti avatar Sep 15 '22 23:09 pjanotti

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).

pellared avatar Sep 22 '22 19:09 pellared