aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lwtrace
diff options
context:
space:
mode:
authorVasily Gerasimov <UgnineSirdis@gmail.com>2022-02-10 16:49:10 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:10 +0300
commit1eb755fbca92172a6aec2f57371b2b3a19dfab43 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/lwtrace
parent6cdc8f140213c595e4ad38bc3d97fcef1146b8c3 (diff)
downloadydb-1eb755fbca92172a6aec2f57371b2b3a19dfab43.tar.gz
Restoring authorship annotation for Vasily Gerasimov <UgnineSirdis@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/lwtrace')
-rw-r--r--library/cpp/lwtrace/event.h2
-rw-r--r--library/cpp/lwtrace/param_traits.h132
-rw-r--r--library/cpp/lwtrace/preprocessor.h6
-rw-r--r--library/cpp/lwtrace/probe.h2
-rw-r--r--library/cpp/lwtrace/signature.h152
-rw-r--r--library/cpp/lwtrace/trace_ut.cpp42
6 files changed, 168 insertions, 168 deletions
diff --git a/library/cpp/lwtrace/event.h b/library/cpp/lwtrace/event.h
index 48fdc6b85a..e53a620c45 100644
--- a/library/cpp/lwtrace/event.h
+++ b/library/cpp/lwtrace/event.h
@@ -2,7 +2,7 @@
#include "preprocessor.h"
#include "signature.h"
-#include "param_traits.h"
+#include "param_traits.h"
#include <library/cpp/lwtrace/protos/lwtrace.pb.h>
diff --git a/library/cpp/lwtrace/param_traits.h b/library/cpp/lwtrace/param_traits.h
index 8ff87efd0b..a0faeb50db 100644
--- a/library/cpp/lwtrace/param_traits.h
+++ b/library/cpp/lwtrace/param_traits.h
@@ -1,66 +1,66 @@
-#pragma once
-#include "signature.h"
-
-#include <util/datetime/base.h>
-#include <util/string/builder.h>
-
-#include <limits>
-
-#ifndef LWTRACE_DISABLE
-
-namespace NLWTrace {
-
- template <>
- struct TParamTraits<TInstant> {
- using TStoreType = double;
- using TFuncParam = TInstant;
-
- inline static void ToString(TStoreType value, TString* out) {
- *out = TParamConv<TStoreType>::ToString(value);
- }
-
- inline static TStoreType ToStoreType(TInstant value) {
- if (value == TInstant::Max()) {
- return std::numeric_limits<TStoreType>::infinity();
- } else {
- return static_cast<TStoreType>(value.MicroSeconds()) / 1000000.0; // seconds count
- }
- }
- };
-
- template <>
- struct TParamTraits<TDuration> {
- using TStoreType = double;
- using TFuncParam = TDuration;
-
- inline static void ToString(TStoreType value, TString* out) {
- *out = TParamConv<TStoreType>::ToString(value);
- }
-
- inline static TStoreType ToStoreType(TDuration value) {
- if (value == TDuration::Max()) {
- return std::numeric_limits<TStoreType>::infinity();
- } else {
- return static_cast<TStoreType>(value.MicroSeconds()) / 1000.0; // milliseconds count
- }
- }
- };
-
- // Param for enum with GENERATE_ENUM_SERIALIZATION enabled or operator<< implemented
- template <class TEnum>
- struct TEnumParamWithSerialization {
- using TStoreType = typename TParamTraits<std::underlying_type_t<TEnum>>::TStoreType;
- using TFuncParam = TEnum;
-
- inline static void ToString(TStoreType stored, TString* out) {
- *out = TStringBuilder() << static_cast<TEnum>(stored) << " (" << stored << ")";
- }
-
- inline static TStoreType ToStoreType(TFuncParam v) {
- return static_cast<TStoreType>(v);
- }
- };
-
-} // namespace NLWTrace
-
-#endif // LWTRACE_DISABLE
+#pragma once
+#include "signature.h"
+
+#include <util/datetime/base.h>
+#include <util/string/builder.h>
+
+#include <limits>
+
+#ifndef LWTRACE_DISABLE
+
+namespace NLWTrace {
+
+ template <>
+ struct TParamTraits<TInstant> {
+ using TStoreType = double;
+ using TFuncParam = TInstant;
+
+ inline static void ToString(TStoreType value, TString* out) {
+ *out = TParamConv<TStoreType>::ToString(value);
+ }
+
+ inline static TStoreType ToStoreType(TInstant value) {
+ if (value == TInstant::Max()) {
+ return std::numeric_limits<TStoreType>::infinity();
+ } else {
+ return static_cast<TStoreType>(value.MicroSeconds()) / 1000000.0; // seconds count
+ }
+ }
+ };
+
+ template <>
+ struct TParamTraits<TDuration> {
+ using TStoreType = double;
+ using TFuncParam = TDuration;
+
+ inline static void ToString(TStoreType value, TString* out) {
+ *out = TParamConv<TStoreType>::ToString(value);
+ }
+
+ inline static TStoreType ToStoreType(TDuration value) {
+ if (value == TDuration::Max()) {
+ return std::numeric_limits<TStoreType>::infinity();
+ } else {
+ return static_cast<TStoreType>(value.MicroSeconds()) / 1000.0; // milliseconds count
+ }
+ }
+ };
+
+ // Param for enum with GENERATE_ENUM_SERIALIZATION enabled or operator<< implemented
+ template <class TEnum>
+ struct TEnumParamWithSerialization {
+ using TStoreType = typename TParamTraits<std::underlying_type_t<TEnum>>::TStoreType;
+ using TFuncParam = TEnum;
+
+ inline static void ToString(TStoreType stored, TString* out) {
+ *out = TStringBuilder() << static_cast<TEnum>(stored) << " (" << stored << ")";
+ }
+
+ inline static TStoreType ToStoreType(TFuncParam v) {
+ return static_cast<TStoreType>(v);
+ }
+ };
+
+} // namespace NLWTrace
+
+#endif // LWTRACE_DISABLE
diff --git a/library/cpp/lwtrace/preprocessor.h b/library/cpp/lwtrace/preprocessor.h
index 205891fd5e..40865467b2 100644
--- a/library/cpp/lwtrace/preprocessor.h
+++ b/library/cpp/lwtrace/preprocessor.h
@@ -57,7 +57,7 @@
/**/
// Use for code generation to handle parameter lists
-// NOTE: this is the only place to change if more parameters needed
+// NOTE: this is the only place to change if more parameters needed
#define FOREACH_PARAMNUM(MACRO, ...) \
MACRO(0, ##__VA_ARGS__) \
MACRO(1, ##__VA_ARGS__) \
@@ -114,9 +114,9 @@
#define LWTRACE_TEMPLATE_PARAMS_NODEF LWTRACE_EXPAND(LWTRACE_EAT FOREACH_PARAMNUM(LWTRACE_TEMPLATE_PARAMS_NODEF_I)(0))
#define LWTRACE_TEMPLATE_ARGS_I(i) (1) TP##i LWTRACE_COMMA
#define LWTRACE_TEMPLATE_ARGS LWTRACE_EXPAND(LWTRACE_EAT FOREACH_PARAMNUM(LWTRACE_TEMPLATE_ARGS_I)(0))
-#define LWTRACE_FUNCTION_PARAMS_I(i) (1) typename ::NLWTrace::TParamTraits<TP##i>::TFuncParam p##i = ERROR_not_enough_parameters() LWTRACE_COMMA
+#define LWTRACE_FUNCTION_PARAMS_I(i) (1) typename ::NLWTrace::TParamTraits<TP##i>::TFuncParam p##i = ERROR_not_enough_parameters() LWTRACE_COMMA
#define LWTRACE_FUNCTION_PARAMS LWTRACE_EXPAND(LWTRACE_EAT FOREACH_PARAMNUM(LWTRACE_FUNCTION_PARAMS_I)(0))
-#define LWTRACE_PREPARE_PARAMS_I(i, params) params.Param[i].template CopyConstruct<typename ::NLWTrace::TParamTraits<TP##i>::TStoreType>(::NLWTrace::TParamTraits<TP##i>::ToStoreType(p##i));
+#define LWTRACE_PREPARE_PARAMS_I(i, params) params.Param[i].template CopyConstruct<typename ::NLWTrace::TParamTraits<TP##i>::TStoreType>(::NLWTrace::TParamTraits<TP##i>::ToStoreType(p##i));
#define LWTRACE_PREPARE_PARAMS(params) \
do { \
FOREACH_PARAMNUM(LWTRACE_PREPARE_PARAMS_I, params) \
diff --git a/library/cpp/lwtrace/probe.h b/library/cpp/lwtrace/probe.h
index d4be4c4f4d..31fa282da3 100644
--- a/library/cpp/lwtrace/probe.h
+++ b/library/cpp/lwtrace/probe.h
@@ -176,7 +176,7 @@ namespace NLWTrace {
inline void PreparePtr<TNil>(const TNil&, const TNil*&) {
}
-#define LWTRACE_SCOPED_FUNCTION_PARAMS_I(i) (1) typename ::NLWTrace::TParamTraits<TP##i>::TFuncParam p##i = ERROR_not_enough_parameters() LWTRACE_COMMA
+#define LWTRACE_SCOPED_FUNCTION_PARAMS_I(i) (1) typename ::NLWTrace::TParamTraits<TP##i>::TFuncParam p##i = ERROR_not_enough_parameters() LWTRACE_COMMA
#define LWTRACE_SCOPED_FUNCTION_PARAMS LWTRACE_EXPAND(LWTRACE_EAT FOREACH_PARAMNUM(LWTRACE_SCOPED_FUNCTION_PARAMS_I)(0))
#define LWTRACE_SCOPED_FUNCTION_PARAMS_BY_REF_I(i) (1) typename ::NLWTrace::TParamTraits<TP##i>::TStoreType& p##i = *(ERROR_not_enough_parameters*)(HidePointerOrigin(nullptr))LWTRACE_COMMA
#define LWTRACE_SCOPED_FUNCTION_PARAMS_BY_REF LWTRACE_EXPAND(LWTRACE_EAT FOREACH_PARAMNUM(LWTRACE_SCOPED_FUNCTION_PARAMS_BY_REF_I)(0))
diff --git a/library/cpp/lwtrace/signature.h b/library/cpp/lwtrace/signature.h
index aaf2e95bc9..868bd9bcf2 100644
--- a/library/cpp/lwtrace/signature.h
+++ b/library/cpp/lwtrace/signature.h
@@ -7,17 +7,17 @@
#include <util/generic/cast.h>
#include <util/generic/string.h>
#include <util/generic/typetraits.h>
-#include <util/string/builder.h>
+#include <util/string/builder.h>
#include <util/string/cast.h>
#include <util/string/printf.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_enum_reflection.h>
-
+
#include <library/cpp/lwtrace/protos/lwtrace.pb.h>
-#include <type_traits>
-
+#include <type_traits>
+
namespace NLWTrace {
// Class to hold parameter values parsed from trace query predicate operators
template <class T>
@@ -465,76 +465,76 @@ namespace NLWTrace {
#undef FOREACH_PARAMTYPE_MACRO
template <class T>
- struct TParamTraits;
-
- // Enum types traits impl.
- template <class TEnum, class = std::enable_if_t<std::is_enum_v<TEnum>>>
- struct TEnumParamTraitsImpl {
- using TStoreType = typename TParamTraits<std::underlying_type_t<TEnum>>::TStoreType;
- using TFuncParam = TEnum;
-
+ struct TParamTraits;
+
+ // Enum types traits impl.
+ template <class TEnum, class = std::enable_if_t<std::is_enum_v<TEnum>>>
+ struct TEnumParamTraitsImpl {
+ using TStoreType = typename TParamTraits<std::underlying_type_t<TEnum>>::TStoreType;
+ using TFuncParam = TEnum;
+
inline static void ToString(typename TTypeTraits<TStoreType>::TFuncParam stored, TString* out) {
- if constexpr (google::protobuf::is_proto_enum<TEnum>::value) {
- const google::protobuf::EnumValueDescriptor* valueDescriptor = google::protobuf::GetEnumDescriptor<TEnum>()->FindValueByNumber(stored);
- if (valueDescriptor) {
- *out = TStringBuilder() << valueDescriptor->name() << " (" << stored << ")";
- } else {
- *out = TParamConv<TStoreType>::ToString(stored);
- }
- } else {
- *out = TParamConv<TStoreType>::ToString(stored);
- }
- }
-
- inline static TStoreType ToStoreType(TFuncParam v) {
- return static_cast<TStoreType>(v);
- }
+ if constexpr (google::protobuf::is_proto_enum<TEnum>::value) {
+ const google::protobuf::EnumValueDescriptor* valueDescriptor = google::protobuf::GetEnumDescriptor<TEnum>()->FindValueByNumber(stored);
+ if (valueDescriptor) {
+ *out = TStringBuilder() << valueDescriptor->name() << " (" << stored << ")";
+ } else {
+ *out = TParamConv<TStoreType>::ToString(stored);
+ }
+ } else {
+ *out = TParamConv<TStoreType>::ToString(stored);
+ }
+ }
+
+ inline static TStoreType ToStoreType(TFuncParam v) {
+ return static_cast<TStoreType>(v);
+ }
};
- template <class TCustomType>
- struct TCustomTraitsImpl {
- using TStoreType = typename TParamTraits<typename TCustomType::TStoreType>::TStoreType; //see STORE_TYPE_AS
- using TFuncParam = typename TCustomType::TFuncParam;
-
- inline static void ToString(typename TTypeTraits<TStoreType>::TFuncParam stored, TString* out) {
- TCustomType::ToString(stored, out);
- }
-
- inline static TStoreType ToStoreType(TFuncParam v) {
- return TCustomType::ToStoreType(v);
- }
- };
-
- template <class T, bool isEnum>
- struct TParamTraitsImpl;
-
- template <class TEnum>
- struct TParamTraitsImpl<TEnum, true> : TEnumParamTraitsImpl<TEnum> {
- };
-
- template <class TCustomType>
- struct TParamTraitsImpl<TCustomType, false> : TCustomTraitsImpl<TCustomType> {
- };
-
- template <class T>
- struct TParamTraits : TParamTraitsImpl<T, std::is_enum_v<T>> {
- };
-
- // Standard stored types traits.
-
+ template <class TCustomType>
+ struct TCustomTraitsImpl {
+ using TStoreType = typename TParamTraits<typename TCustomType::TStoreType>::TStoreType; //see STORE_TYPE_AS
+ using TFuncParam = typename TCustomType::TFuncParam;
+
+ inline static void ToString(typename TTypeTraits<TStoreType>::TFuncParam stored, TString* out) {
+ TCustomType::ToString(stored, out);
+ }
+
+ inline static TStoreType ToStoreType(TFuncParam v) {
+ return TCustomType::ToStoreType(v);
+ }
+ };
+
+ template <class T, bool isEnum>
+ struct TParamTraitsImpl;
+
+ template <class TEnum>
+ struct TParamTraitsImpl<TEnum, true> : TEnumParamTraitsImpl<TEnum> {
+ };
+
+ template <class TCustomType>
+ struct TParamTraitsImpl<TCustomType, false> : TCustomTraitsImpl<TCustomType> {
+ };
+
+ template <class T>
+ struct TParamTraits : TParamTraitsImpl<T, std::is_enum_v<T>> {
+ };
+
+ // Standard stored types traits.
+
#define STORE_TYPE_AS(input_t, store_as_t) \
template <> \
struct TParamTraits<input_t> { \
- using TStoreType = store_as_t; \
- using TFuncParam = typename TTypeTraits<input_t>::TFuncParam; \
- \
- inline static void ToString(typename TTypeTraits<TStoreType>::TFuncParam stored, TString* out) { \
+ using TStoreType = store_as_t; \
+ using TFuncParam = typename TTypeTraits<input_t>::TFuncParam; \
+ \
+ inline static void ToString(typename TTypeTraits<TStoreType>::TFuncParam stored, TString* out) { \
*out = TParamConv<TStoreType>::ToString(stored); \
} \
- \
- inline static TStoreType ToStoreType(TFuncParam v) { \
- return v; \
- } \
+ \
+ inline static TStoreType ToStoreType(TFuncParam v) { \
+ return v; \
+ } \
}; \
/**/
STORE_TYPE_AS(ui8, ui64);
@@ -550,18 +550,18 @@ namespace NLWTrace {
#undef STORE_TYPE_AS
#undef FOREACH_PARAMTYPE_MACRO
- // Nil type staits.
+ // Nil type staits.
template <>
struct TParamTraits<TNil> {
- using TStoreType = TNil;
- using TFuncParam = TTypeTraits<TNil>::TFuncParam;
-
- inline static void ToString(typename TTypeTraits<TNil>::TFuncParam, TString*) {
- }
-
- inline static TNil ToStoreType(TFuncParam v) {
- return v;
- }
+ using TStoreType = TNil;
+ using TFuncParam = TTypeTraits<TNil>::TFuncParam;
+
+ inline static void ToString(typename TTypeTraits<TNil>::TFuncParam, TString*) {
+ }
+
+ inline static TNil ToStoreType(TFuncParam v) {
+ return v;
+ }
};
inline EParamTypePb ParamTypeToProtobuf(const char* paramType) {
diff --git a/library/cpp/lwtrace/trace_ut.cpp b/library/cpp/lwtrace/trace_ut.cpp
index fac6869892..cb03e4fbde 100644
--- a/library/cpp/lwtrace/trace_ut.cpp
+++ b/library/cpp/lwtrace/trace_ut.cpp
@@ -1,28 +1,28 @@
#include "all.h"
#include <library/cpp/lwtrace/protos/lwtrace.pb.h>
-
+
#include <library/cpp/testing/unittest/registar.h>
#include <google/protobuf/text_format.h>
-enum ESimpleEnum {
- ValueA,
- ValueB,
-};
-
-enum class EEnumClass {
- ValueC,
- ValueD,
-};
-
+enum ESimpleEnum {
+ ValueA,
+ ValueB,
+};
+
+enum class EEnumClass {
+ ValueC,
+ ValueD,
+};
+
#define LWTRACE_UT_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \
PROBE(NoParam, GROUPS("Group"), TYPES(), NAMES()) \
PROBE(IntParam, GROUPS("Group"), TYPES(ui32), NAMES("value")) \
PROBE(StringParam, GROUPS("Group"), TYPES(TString), NAMES("value")) \
PROBE(SymbolParam, GROUPS("Group"), TYPES(NLWTrace::TSymbol), NAMES("symbol")) \
PROBE(CheckParam, GROUPS("Group"), TYPES(NLWTrace::TCheck), NAMES("value")) \
- PROBE(EnumParams, GROUPS("Group"), TYPES(ESimpleEnum, EEnumClass), NAMES("simpleEnum", "enumClass")) \
+ PROBE(EnumParams, GROUPS("Group"), TYPES(ESimpleEnum, EEnumClass), NAMES("simpleEnum", "enumClass")) \
PROBE(InstantParam, GROUPS("Group"), TYPES(TInstant), NAMES("value")) \
PROBE(DurationParam, GROUPS("Group"), TYPES(TDuration), NAMES("value")) \
PROBE(ProtoEnum, GROUPS("Group"), TYPES(NLWTrace::EOperatorType), NAMES("value")) \
@@ -61,13 +61,13 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) {
}
} reader;
mngr.ReadLog("Query1", reader);
-
- LWPROBE(EnumParams, ValueA, EEnumClass::ValueC);
- LWPROBE(InstantParam, TInstant::Seconds(42));
- LWPROBE(DurationParam, TDuration::MilliSeconds(146));
+
+ LWPROBE(EnumParams, ValueA, EEnumClass::ValueC);
+ LWPROBE(InstantParam, TInstant::Seconds(42));
+ LWPROBE(DurationParam, TDuration::MilliSeconds(146));
LWPROBE(ProtoEnum, OT_EQ);
}
-
+
Y_UNIT_TEST(Predicate) {
TManager mngr(*Singleton<TProbeRegistry>(), true);
TQuery q;
@@ -542,13 +542,13 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) {
UNIT_ASSERT(t1.NanoSeconds() - t0.NanoSeconds() >= sleepTimeNs);
}
- Y_UNIT_TEST(ProtoEnumTraits) {
+ Y_UNIT_TEST(ProtoEnumTraits) {
using TPbEnumTraits = TParamTraits<EOperatorType>;
- TString str;
+ TString str;
TPbEnumTraits::ToString(TPbEnumTraits::ToStoreType(OT_EQ), &str);
UNIT_ASSERT_STRINGS_EQUAL(str, "OT_EQ (0)");
- }
-
+ }
+
Y_UNIT_TEST(Track) {
TManager mngr(*Singleton<TProbeRegistry>(), true);
TQuery q;