diff options
author | serxa <serxa@yandex-team.ru> | 2022-02-10 16:49:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:08 +0300 |
commit | d6d7db348c2cc64e71243cab9940ee6778f4317d (patch) | |
tree | bac67f42a02f9368eb4d329f5d79b77d0a6adc18 /library/cpp/lwtrace/start.cpp | |
parent | 8d57b69dee81198a59c39e64704f7dc9f04b4fbf (diff) | |
download | ydb-d6d7db348c2cc64e71243cab9940ee6778f4317d.tar.gz |
Restoring authorship annotation for <serxa@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/lwtrace/start.cpp')
-rw-r--r-- | library/cpp/lwtrace/start.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/library/cpp/lwtrace/start.cpp b/library/cpp/lwtrace/start.cpp index 121d5472b6..7d17d6c572 100644 --- a/library/cpp/lwtrace/start.cpp +++ b/library/cpp/lwtrace/start.cpp @@ -14,56 +14,56 @@ using namespace NLWTrace; namespace { - struct TTraceManagerHolder { - TManager TraceManager; - TTraceManagerHolder() - : TraceManager(*Singleton<TProbeRegistry>(), true) - { - } - }; - - void TraceFromEnv(TString path) { - TString script = TUnbufferedFileInput(path).ReadAll(); - TQuery query; - bool ok = google::protobuf::TextFormat::ParseFromString(script, &query); - Y_VERIFY(ok, "failed to parse protobuf"); - Singleton<TTraceManagerHolder>()->TraceManager.New("env", query); - } - -} // anonymous namespace - -void NLWTrace::StartLwtraceFromEnv() { - static bool started = false; - if (started) { - return; - } else { - started = true; - } - + struct TTraceManagerHolder { + TManager TraceManager; + TTraceManagerHolder() + : TraceManager(*Singleton<TProbeRegistry>(), true) + { + } + }; + + void TraceFromEnv(TString path) { + TString script = TUnbufferedFileInput(path).ReadAll(); + TQuery query; + bool ok = google::protobuf::TextFormat::ParseFromString(script, &query); + Y_VERIFY(ok, "failed to parse protobuf"); + Singleton<TTraceManagerHolder>()->TraceManager.New("env", query); + } + +} // anonymous namespace + +void NLWTrace::StartLwtraceFromEnv() { + static bool started = false; + if (started) { + return; + } else { + started = true; + } + TString path = GetEnv("LWTRACE"); if (!path) { return; } try { - TraceFromEnv(path); + TraceFromEnv(path); } catch (...) { Cerr << "failed to load lwtrace script: " << CurrentExceptionMessage() << "\n"; abort(); } } - -void NLWTrace::StartLwtraceFromEnv(std::function<void(TManager&)> prepare) { + +void NLWTrace::StartLwtraceFromEnv(std::function<void(TManager&)> prepare) { TString path = GetEnv("LWTRACE"); if (Y_LIKELY(!path)) { - return; - } - - try { - prepare(Singleton<TTraceManagerHolder>()->TraceManager); - TraceFromEnv(path); - } catch (...) { - Cerr << "failed to load lwtrace script: " << CurrentExceptionMessage() << "\n"; - abort(); - } -} + return; + } + + try { + prepare(Singleton<TTraceManagerHolder>()->TraceManager); + TraceFromEnv(path); + } catch (...) { + Cerr << "failed to load lwtrace script: " << CurrentExceptionMessage() << "\n"; + abort(); + } +} |