Comments (6)
I have used mock tracer on a number of occasions to verify that some instrumentation is done correctly. However, I never needed to also verify that baggage is propagated. Could you describe the use case when it is needed? The mock tracer is not supposed to be used in real scenarios.
from opentracing-java.
Understood about proper use of the mock tracer. The only "real scenario" here is a real unit test.
My use case requires a specialized carrier. It is agnostic about the tracer implementation and uses the conventional Java API for Tracer
, Span
and SpanContext
. It communicates with the Tracer
via a wrapper that makes the specialized carrier look like a simple TEXT_MAP
, using inject
and extract
to pass the SpanContext
back and forth. That part works just fine for mock span and trace IDs.
Some of the unit tests for the carrier wrapper explicitly include baggage items. They should make the round trip alongside the span and trace IDs to carrier and back via inject
and extract
functions supplied by the (in this case mock) Tracer
.
In more detail, the test is:
- Use mock tracer to start a parent span
- Add a few baggage items
inject
aSpanContext
representation into the specialized carrierextract
theSpanContext
from the specialized carrier- Check trace and span IDs were transmitted via the carrier (passes)
- Check the baggage items were transmitted too (fails)
In other words, I need mock baggage items to test whether my own carrier code handles baggage items correctly. Took me a little while to figure out why it kept failing.
from opentracing-java.
I did send a PR for the enhancement. The code itself and corresponding test case might clarify more than my prose explanation. All it does is
- Add all the baggage items to the Map before adding the span and trace ids (so baggage items can't interfere with trace or span)
- Extract items that aren't the span or trace into baggage items
The PR should be backward compatible. It doesn't interfere with existing mock span or trace id, and existing tests presumably wouldn't include baggage items since they don't work.
from opentracing-java.
Unless setting & reading the baggage is somehow critical to the behavior of your solution, it seems like it's redundant to test if your protocol is correctly propagating the baggage given that you already confirm it's propagating the span context - it looks more like you're testing the tracer implementation rather than your own code.
But I don't have objections to the PR itself.
from opentracing-java.
It's critical that my carrier implementation carry the baggage items because it's part of the API for a SpanContext
. You may well be correct that the test is at least partly redundant, and I could have tested my carrier more directly. The fact that the test passed immediately when I patched the MockTracer
would tend to support that view. Adding baggage handling to MockTracer
certainly made my unit tests more readable and understandable, and seems more generally useful.
from opentracing-java.
Closed by PR#129
from opentracing-java.
Related Issues (20)
- Why doesn't Span support try-with-resources? HOT 4
- Docs reference outdated API HOT 3
- Correct way how to not report fast spans HOT 12
- Unit tests fail with "AbstractMethodError" HOT 2
- Access Custom Tracer's fields through GlobalTracer.get() HOT 4
- Overriding timestamp on spans HOT 3
- TextMapInjectAdapter does not implement TextMap HOT 1
- Not able to get simple opentracing code to work HOT 3
- Missing ScopeManager.active() method HOT 1
- `NoopSpan` cannot be used as a default, parent span without throwing Exception. HOT 6
- try-with-resources (which doesn't work) is still the main documented way to use OpenTracing in java
- Breaking change from 0.31 to 0.33 HOT 6
- TracingKafkaConsumer incompatible with Kafka >= 2.4.0 HOT 1
- access to registered tracer
- Migrating the CI CD from Travis to GitHub Actions HOT 4
- Are there version mappings to OpenTracing Specification?
- Span object is null when passing RequestEntity<?> as a request parameter
- Possible to terminate span on remote system? HOT 2
- State of opentracing-java HOT 1
- Why are some tags missing in the releases? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentracing-java.