Open
Description
Currently there's no out of the box way to set up a test with tracing turned on that would collect spans in a queue for further analysis. What is required now from the user is to either use a TestSpanHandler
from Brave or ArrayListSpanReporter
from OTel.
With the changes in this PR we're introducing an abstract concept of aggregating spans for Micrometer Tracing API.
In Spring Boot we would need the @TracingTest
test slice that would turn on the @AutoConfigureObservability
with tracing on and would register the TestSpanHandler
as a bean.
related issue
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
wilkinsona commentedon Feb 8, 2024
A tracing slice would limit the context to only the beans that are related to tracing. It doesn't sound like that's what we want here. Don't we just want a way to opt in to the registration of the
TestSpanHandler
bean, leaving all of the context's other beans pretty much as they are?marcingrzejszczak commentedon Feb 8, 2024
Yeah, you're right. That would be the way to go.
JordiMartinezVicent commentedon Feb 8, 2024
Just a couple of points:
Otel considerations:
Currently a BatchSpanProcessor at OpenTelemetryAutoConfiguration being used. It reports the span asynchronously. I think that it should not be desirable in tests as it could cause race conditions. A way of solve the issue would be to override the SdkTracerProvider with a SimpleSpanProcessor instead:
Brave considerations
It would be nice to auto-configure a Sampler.ALWAYS_SAMPLE for testing purposes for the user not to worry about it.
Also we would need some mechanism to clear the spans reported between tests (JUnit extension??)
marcingrzejszczak commentedon Feb 9, 2024
As for the test extension I guess we should summon @sbrannen
[-]Add a @TracingTest test slice[/-][+]Auto-configure testing support for tracing[/+]