Add reset to GlobalTracer
See original GitHub issueRelated to https://github.com/opentracing/opentracing-java/issues/170.
At the moment there is no reset method on GlobaLTracer
which makes testing hard. The solution might be to fork jvm or use test-jar
. However most people don’t know that there is a test-jar. The test jar is also not a preferred way to provide these type of functionality.
If the reset API is well documented I don’t think it will be misused.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
io.opentracing.Tracer.scopeManager java code examples
public static void recordEvent(String event, Tracer tracer) { if (tracer == null) { tracer = GlobalTracer.get(); } Scope scope = tracer.
Read more >Tracing .NET Framework Applications - Datadog Docs
NET application: Add the Datadog.Trace NuGet package to your application. In your application code, access the global tracer through the Datadog.Trace.
Read more >opentrace activeSpan is null - Stack Overflow
Instead of changing individual methods, I have added AOP/aspectJ to add span.But when i try to do. Span currentSpan = GlobalTracer.get().
Read more >GO packages new / opentracing / Opentracing Go · GitLab
API overview for those adding instrumentation. Everyday consumers of this opentracing package really only need to worry about a couple of key abstractions: ......
Read more >collection_crud_test.go - gocb - Gitiles - Code Review - Couchbase
AssertKVMetrics(meterNameCBOperations, "insert", 2, false) ... for _, testCase := range testCases {. globalTracer.Reset(). globalMeter.Reset(). suite.T().
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think a better suggestion would be to not design your under test code to depend on global tracer. Globals and unit tests don’t go together well. For example, if you’re creating some middleware, always make it accept the tracer rather than depending on global tracer directly.
The original proposal had a reset functionality and the consensus then was that having at-most-once semantics for the GlobalTracer were desirable.
Adding a reset can cause issues in an application by addition of a new library whose author misunderstood or didn’t read the documentation. These kind of bugs are not my favorite to solve!
My opinion: Adding functionality to production code to facilitate testing is bad practice and should be avoided.