aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2022-08-22 16:24:07 +0300
committeralexvru <alexvru@ydb.tech>2022-08-22 16:24:07 +0300
commit54345a22b199ef455a73f86e69f9597678b2dfab (patch)
treef648f5404c966991b3fce9b11f129346ee7aa1fb
parent712d7d37a939122f4dca6ce6a035d56cf57db852 (diff)
downloadydb-54345a22b199ef455a73f86e69f9597678b2dfab.tar.gz
Fix false positive Y_VERIFY
-rw-r--r--library/cpp/actors/wilson/wilson_span.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/library/cpp/actors/wilson/wilson_span.h b/library/cpp/actors/wilson/wilson_span.h
index a6ea2d921c..05dd5a8343 100644
--- a/library/cpp/actors/wilson/wilson_span.h
+++ b/library/cpp/actors/wilson/wilson_span.h
@@ -55,6 +55,7 @@ namespace NWilson {
TFlags Flags;
int UncaughtExceptions = std::uncaught_exceptions();
bool Sent = false;
+ bool Ignored = false;
TData(TInstant startTime, ui64 startCycles, TTraceId traceId, TFlags flags)
: StartTime(startTime)
@@ -64,7 +65,7 @@ namespace NWilson {
{}
~TData() {
- Y_VERIFY_DEBUG(Sent);
+ Y_VERIFY_DEBUG(Sent || Ignored);
}
};
@@ -94,7 +95,7 @@ namespace NWilson {
Attribute("node_id", NActors::TActivationContext::ActorSystem()->NodeId);
} else {
- Data->Sent = true; // ignore this span due to verbosity mismatch, still allowing child spans to be created
+ Data->Ignored = true; // ignore this span due to verbosity mismatch, still allowing child spans to be created
}
}
}
@@ -124,14 +125,14 @@ namespace NWilson {
}
explicit operator bool() const {
- return Data && !Data->Sent;
+ return Data && !Data->Sent && !Data->Ignored;
}
TSpan& EnableAutoEnd() {
if (Y_UNLIKELY(*this)) {
Data->Flags |= EFlags::AUTO_END;
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
return *this;
}
@@ -140,7 +141,7 @@ namespace NWilson {
if (Y_UNLIKELY(*this)) {
// update relation in data somehow
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
return *this;
}
@@ -149,7 +150,7 @@ namespace NWilson {
if (Y_UNLIKELY(*this)) {
Data->Span.set_name(std::move(name));
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
return *this;
}
@@ -158,7 +159,7 @@ namespace NWilson {
if (Y_UNLIKELY(*this)) {
SerializeKeyValue(std::move(name), std::move(value), Data->Span.add_attributes());
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
return *this;
}
@@ -172,7 +173,7 @@ namespace NWilson {
SerializeKeyValue(std::move(key), std::move(value), event->add_attributes());
}
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
return *this;
}
@@ -186,7 +187,7 @@ namespace NWilson {
SerializeKeyValue(std::move(key), std::move(value), link->add_attributes());
}
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
return *this;
}
@@ -197,7 +198,7 @@ namespace NWilson {
status->set_code(NTraceProto::Status::STATUS_CODE_OK);
End();
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
}
@@ -208,7 +209,7 @@ namespace NWilson {
status->set_message(std::move(error));
End();
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
}
@@ -219,7 +220,7 @@ namespace NWilson {
Data->Span.set_end_time_unix_nano(TimeUnixNano());
Send();
} else {
- Y_VERIFY_DEBUG(!Data, "span has been ended");
+ VerifyNotSent();
}
}
@@ -234,6 +235,10 @@ namespace NWilson {
const TInstant now = Data->StartTime + CyclesToDuration(GetCycleCount() - Data->StartCycles);
return now.NanoSeconds();
}
+
+ void VerifyNotSent() {
+ Y_VERIFY_DEBUG(!Data || !Data->Sent, "span has been ended");
+ }
};
} // NWilson