aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lwtrace/example5
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/lwtrace/example5
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/lwtrace/example5')
-rw-r--r--library/cpp/lwtrace/example5/example_query.tr9
-rw-r--r--library/cpp/lwtrace/example5/lwtrace_example5.cpp30
-rwxr-xr-xlibrary/cpp/lwtrace/example5/start_with_query.sh3
-rw-r--r--library/cpp/lwtrace/example5/ya.make13
4 files changed, 55 insertions, 0 deletions
diff --git a/library/cpp/lwtrace/example5/example_query.tr b/library/cpp/lwtrace/example5/example_query.tr
new file mode 100644
index 0000000000..90887d4ddf
--- /dev/null
+++ b/library/cpp/lwtrace/example5/example_query.tr
@@ -0,0 +1,9 @@
+Blocks {
+ ProbeDesc {
+ Group: "LWTRACE_EXAMPLE_PROVIDER"
+ }
+ Action {
+ PrintToStderrAction { }
+ }
+}
+
diff --git a/library/cpp/lwtrace/example5/lwtrace_example5.cpp b/library/cpp/lwtrace/example5/lwtrace_example5.cpp
new file mode 100644
index 0000000000..1c324473c2
--- /dev/null
+++ b/library/cpp/lwtrace/example5/lwtrace_example5.cpp
@@ -0,0 +1,30 @@
+#include <library/cpp/lwtrace/all.h>
+#include <library/cpp/lwtrace/lwprobe.h>
+
+template <ui64 N>
+ui64 Fact() {
+ ui64 result = N * Fact<N - 1>();
+
+#ifndef LWTRACE_DISABLE
+ // Note that probe is create on the first pass
+ // LWTRACE_DECLARE_PROVIDER and LWTRACE_DEFINE_PROVIDER are not needed
+ // (Provider is created implicitly)
+ static NLWTrace::TLWProbe<ui64> factProbe(
+ "LWTRACE_EXAMPLE_PROVIDER", "FactProbe_" + ToString(N), {}, {"result"});
+
+ LWPROBE_OBJ(factProbe, result);
+#endif // LWTRACE_DISABLE
+ return result;
+}
+
+template <>
+ui64 Fact<0>() {
+ return 1;
+}
+
+int main() {
+ Fact<6>(); // First run is required to create probes we can use later in trace query
+ NLWTrace::StartLwtraceFromEnv(); // parse trace query and create trace session
+ Cout << Fact<6>() << Endl; // actually trigger probes
+ return 0;
+}
diff --git a/library/cpp/lwtrace/example5/start_with_query.sh b/library/cpp/lwtrace/example5/start_with_query.sh
new file mode 100755
index 0000000000..4df5e4e47c
--- /dev/null
+++ b/library/cpp/lwtrace/example5/start_with_query.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+export LWTRACE="example_query.tr"
+./lwtrace-example5
diff --git a/library/cpp/lwtrace/example5/ya.make b/library/cpp/lwtrace/example5/ya.make
new file mode 100644
index 0000000000..06dd4dc569
--- /dev/null
+++ b/library/cpp/lwtrace/example5/ya.make
@@ -0,0 +1,13 @@
+PROGRAM(lwtrace-example5)
+
+OWNER(serxa)
+
+SRCS(
+ lwtrace_example5.cpp
+)
+
+PEERDIR(
+ library/cpp/lwtrace
+)
+
+END()