initialize all members in Span

This commit is contained in:
Xiaoxi Wang 2022-09-03 15:39:36 -07:00
parent f1910fdc54
commit 9461450081
1 changed files with 5 additions and 3 deletions

View File

@ -50,8 +50,7 @@ struct SpanContext {
SpanContext() : traceID(UID()), spanID(0), m_Flags(TraceFlags::unsampled) {}
SpanContext(UID traceID, uint64_t spanID, TraceFlags flags) : traceID(traceID), spanID(spanID), m_Flags(flags) {}
SpanContext(UID traceID, uint64_t spanID) : traceID(traceID), spanID(spanID), m_Flags(TraceFlags::unsampled) {}
SpanContext(Arena arena, const SpanContext& span)
: traceID(span.traceID), spanID(span.spanID), m_Flags(span.m_Flags) {}
SpanContext(const SpanContext& span) = default;
bool isSampled() const { return (m_Flags & TraceFlags::sampled) == TraceFlags::sampled; }
std::string toString() const { return format("%016llx%016llx%016llx", traceID.first(), traceID.second(), spanID); };
bool isValid() const { return traceID.first() != 0 && traceID.second() != 0 && spanID != 0; }
@ -62,6 +61,9 @@ struct SpanContext {
}
};
template <>
struct flow_ref<SpanContext> : std::false_type {};
// Span
//
// Span is a tracing implementation which, for the most part, complies with the W3C Trace Context specification
@ -155,7 +157,7 @@ public:
// We've determined for initial tracing release, spans with only a location will not be traced.
// Generally these are for background processes, some are called infrequently, while others may be high volume.
// TODO: review and address in subsequent PRs.
Span(const Location& location) : location(location), begin(g_network->now()) {}
explicit Span(const Location& location) : Span(location, SpanContext()) {}
Span(const Span&) = delete;
Span(Span&& o) {