question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add reset to GlobalTracer

See original GitHub issue

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

cc @bobmcwhirter

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
yurishkurocommented, Aug 14, 2018

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.

1reaction
sjoerdtalsmacommented, Jul 26, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found