-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TestSpanReporter #463
Comments
You might want to take a look at what we are doing in the samples repo (e.g.:
Yepp, this should go to the Boot issue tracker, please add a comment here if you create one.
This is expected, You might want to look at the
I think what you described is very similar to what we have with |
I have just open a similar issue to the Spring Boot at spring-projects/spring-boot#38796 I think that the key would be to have some mechanism to:
I have created a personal repo with an approach to solve it (maybe it is a naive approach XD) . You can take a look at https://github.com/JordiMartinezVicent/spring-boot-tracing-test/
In my approach I have created a JUnit extension to manage it. With which I clear the collected spans. |
@JordiMartinezVicent |
Sure! We could use the brave.test.TestSpanHandler to extend the tool with brave implementation. Besides, in my example I use the io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter which implements SpanExporter, the same as the ArrayListSpanProcessor. I do not see clearly the difference between both... but yes, the tool could use the most convenient implementation. What I would do, would be to not to couple the user's tests to a specific implementation (brave or otel) but to create a generic interface, like SpanCollector with which to retrive the spans. |
This makes sense and I asked the same question yesterday, I think it would be beneficial collecting Micrometer Tracing's spans instead of the underlying implementation's. This would also ease migration. @marcingrzejszczak Should we deprecate ArrayListSpanProcessor in favor of io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter? |
Actually the io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter is also an otel implementation. What I meant is that I do not know the differences between them. In my example, the user's tests uses the interface SpanCollector which is implemented by OtelInMemoryExporterSpanCollector which collect the otel spans and transforms them to io.micrometer.tracing.exporter.FinishedSpan (which are not coupled to the implementation) and can be used with the micrometer TracingAssertions. |
I didn't know that there is a InMemorySpanExporter . Sure we can deprecate Created an issue here. |
I have just updated my example to add the brave implementation. (Note that I could not use the TestSpanHandler as it is placed at brave's test source). Also I have refactor it to better fit the packages to the following proposal. As we were saying, it would need to have some classes at SpringBoot project and others at micrometer's. I would place the micromter classes at
Having said that, I would place the code of my example's package
On the other hand, the SpringBoot's would be:
And finally, we have the junit5 extension TracingExtension which, as @jonatan-ivanov told, to clean-up the spans collected at the test. I do not know where I would place the extension.. as it needs the spring context to work. What do you think? If you agree that it is a worthy tool and (at least) the micrometer's code would be well placed there, I can open a PR with this and start working there. |
Sorry for the late reply. I think I like the idea of having a generic
Do you want to create such a PR in Micrometer Tracing? Once that is merged, we can add auto-configuration for this in Boot. @marcingrzejszczak What do you think? |
I think we should do it like this
Additional features that we could consider is to automatically wrap each test method with a span and log out its identifiers. That way the test suite could be pushed to a tracing visualization system too. |
I've created a PR here, please tell me what you think. Of course Spring Boot would require to add the |
I've created an issue in Spring Boot here |
Also we would need a mechanism to clear that queue between tests. (JUnit extension?) |
Recently I had the need of doing some integration tests that include components declared as Beans which generate traces and I had some drawbacks. I would like to share them with you and if you agree, I could contribute to the repo with the solution I found. (Not sure if this is the right repo, as micrometer-tracing does not include Spring Boot. If it is not, I would appreciate your opinion and the redirection to the right repo).
On one hand, I tried the approach of using the
micrometer-tracing-test
injecting theSimpleTracer
as a bean, so the spring components make use of it. But I realized that some components are not executed. For example:io.micrometer.tracing.otel.bridge.Slf4JBaggageEventListener
(otel is the implementation which I am using at the project) or io.opentelemetry.sdk.trace.SpanProcessor. But alsoio.micrometer.tracing.exporter.SpanFilter
that although they are generic, they are called by the implementation bridge. (For example fromio.micrometer.tracing.otel.bridge.CompositeSpanExporter
).On the other hand, I tried to use the
micrometer-tracing-integration-test
but I could not publish the Tracer created there as a bean.Having said that, I would suggest to have some tracing testing tool which integrates with Spring Boot and can make test like the following:
Where the key points would be:
@TracingTest
would declare the tracing beans to be used by Spring Boot auto-configurations@TracingTest
would contain a junit extension to manage the tests lifecycle.I have a naive approach with the opentelemetry vendor. If you feel that it could be useful, I could share it with you, and if you like it, contribute to the project.
The text was updated successfully, but these errors were encountered: