common/tracer: fix decoding when jaeger tracing is disabled

We aren't currently using jaeger tracing on Windows. The issue is
that Windows hosts (or any other host that doesn't use jaeger)
are experiencing message decoding failures after a recent change [1].

This change updates the tracer encoding so that messages from
non-jaeger hosts may be decoded by services that use jaeger.

[1] https://github.com/ceph/ceph/pull/47457

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
This commit is contained in:
Lucian Petrut 2023-04-12 09:39:52 +00:00
parent 80d79609b3
commit 3701ffa673

View File

@ -144,8 +144,21 @@ struct Tracer {
jspan add_span(std::string_view span_name, const jspan_context& parent_ctx) { return {}; }
void init(std::string_view service_name) {}
};
inline void encode(const jspan_context& span, bufferlist& bl, uint64_t f=0) {}
inline void decode(jspan_context& span_ctx, ceph::buffer::list::const_iterator& bl) {}
inline void encode(const jspan_context& span_ctx, bufferlist& bl, uint64_t f = 0) {
ENCODE_START(1, 1, bl);
// jaeger is missing, set "is_valid" to false.
bool is_valid = false;
encode(is_valid, bl);
ENCODE_FINISH(bl);
}
inline void decode(jspan_context& span_ctx, bufferlist::const_iterator& bl) {
DECODE_START(254, bl);
// jaeger is missing, consume the buffer but do not decode it.
DECODE_FINISH(bl);
}
} // namespace tracing
#endif // !HAVE_JAEGER