aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-08-27 19:05:17 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-08-27 19:13:42 +0300
commitbe759e96631856b564ad6a7b082f810128566ac0 (patch)
tree09b245607459fbebb6d54f33eaaf2a8850348f1c
parent82895e6864700905b7420b41c6cdf9285533ad1e (diff)
downloadydb-be759e96631856b564ad6a7b082f810128566ac0.tar.gz
Intermediate changes
-rw-r--r--yt/yt/library/tracing/jaeger/private.h20
-rw-r--r--yt/yt/library/tracing/jaeger/sampler.cpp29
-rw-r--r--yt/yt/library/tracing/jaeger/sampler.h13
-rw-r--r--yt/yt/library/tracing/jaeger/tracer.cpp11
-rw-r--r--yt/yt/library/tracing/jaeger/tracer.h2
5 files changed, 46 insertions, 29 deletions
diff --git a/yt/yt/library/tracing/jaeger/private.h b/yt/yt/library/tracing/jaeger/private.h
new file mode 100644
index 0000000000..f4bc091225
--- /dev/null
+++ b/yt/yt/library/tracing/jaeger/private.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "public.h"
+
+#include <yt/yt/library/profiling/sensor.h>
+
+#include <library/cpp/yt/misc/global.h>
+
+#include <library/cpp/yt/logging/logger.h>
+
+namespace NYT::NTracing {
+
+////////////////////////////////////////////////////////////////////////////////
+
+YT_DEFINE_GLOBAL(const NLogging::TLogger, JaegerLogger, "Jaeger");
+YT_DEFINE_GLOBAL(const NProfiling::TProfiler, TracingProfiler, "/tracing");
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT::NTracing
diff --git a/yt/yt/library/tracing/jaeger/sampler.cpp b/yt/yt/library/tracing/jaeger/sampler.cpp
index f9e137d91a..e77b60e767 100644
--- a/yt/yt/library/tracing/jaeger/sampler.cpp
+++ b/yt/yt/library/tracing/jaeger/sampler.cpp
@@ -7,10 +7,6 @@ using namespace NProfiling;
////////////////////////////////////////////////////////////////////////////////
-YT_DEFINE_GLOBAL(const NProfiling::TProfiler, Profiler, "/jaeger");
-
-////////////////////////////////////////////////////////////////////////////////
-
void TSamplerConfig::Register(TRegistrar registrar)
{
registrar.Parameter("global_sample_rate", &TThis::GlobalSampleRate)
@@ -47,25 +43,24 @@ bool TSampler::TUserState::TrySampleByMinCount(ui64 minCount, TCpuDuration perio
return Sampled.fetch_add(1) < minCount;
}
-TSampler::TSampler()
- : Config_(New<TSamplerConfig>())
- , TracesSampled_(Profiler().WithHot().Counter("/traces_sampled"))
-{ }
-
-TSampler::TSampler(const TSamplerConfigPtr& config)
- : Config_(config)
+TSampler::TSampler(
+ TSamplerConfigPtr config,
+ const TProfiler& profiler)
+ : Config_(std::move(config))
+ , Profiler_(profiler.WithHot())
+ , TracesSampled_(Profiler_.Counter("/traces_sampled"))
{ }
void TSampler::SampleTraceContext(const TString& user, const TTraceContextPtr& traceContext)
{
auto config = Config_.Acquire();
- auto [userState, inserted] = Users_.FindOrInsert(user, [&user] {
+ auto [userState, inserted] = Users_.FindOrInsert(user, [&] {
auto state = New<TUserState>();
- auto profiler = Profiler().WithSparse().WithHot().WithTag("user", user);
- state->TracesSampledByUser = profiler.WithSparse().Counter("/traces_sampled_by_user");
- state->TracesSampledByProbability = profiler.WithSparse().Counter("/traces_sampled_by_probability");
+ auto profiler = Profiler_.WithSparse().WithTag("user", user);
+ state->TracesSampledByUser = profiler.Counter("/traces_sampled_by_user");
+ state->TracesSampledByProbability = profiler.Counter("/traces_sampled_by_probability");
return state;
});
@@ -115,9 +110,9 @@ void TSampler::SampleTraceContext(const TString& user, const TTraceContextPtr& t
}
}
-void TSampler::UpdateConfig(const TSamplerConfigPtr& config)
+void TSampler::UpdateConfig(TSamplerConfigPtr config)
{
- Config_.Store(config);
+ Config_.Store(std::move(config));
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/library/tracing/jaeger/sampler.h b/yt/yt/library/tracing/jaeger/sampler.h
index 57119f0441..1ae7563040 100644
--- a/yt/yt/library/tracing/jaeger/sampler.h
+++ b/yt/yt/library/tracing/jaeger/sampler.h
@@ -1,8 +1,6 @@
#pragma once
-#include "public.h"
-
-#include <yt/yt/library/profiling/sensor.h>
+#include "private.h"
#include <yt/yt/library/syncmap/map.h>
@@ -47,16 +45,19 @@ class TSampler
: public TRefCounted
{
public:
- TSampler();
- explicit TSampler(const TSamplerConfigPtr& config);
+ explicit TSampler(
+ TSamplerConfigPtr config = New<TSamplerConfig>(),
+ const NProfiling::TProfiler& profiler = TracingProfiler());
void SampleTraceContext(const TString& user, const TTraceContextPtr& traceContext);
- void UpdateConfig(const TSamplerConfigPtr& config);
+ void UpdateConfig(TSamplerConfigPtr config);
private:
TAtomicIntrusivePtr<TSamplerConfig> Config_;
+ NProfiling::TProfiler Profiler_;
+
struct TUserState final
{
std::atomic<ui64> Sampled = {0};
diff --git a/yt/yt/library/tracing/jaeger/tracer.cpp b/yt/yt/library/tracing/jaeger/tracer.cpp
index 23accc377d..c3b254e7b5 100644
--- a/yt/yt/library/tracing/jaeger/tracer.cpp
+++ b/yt/yt/library/tracing/jaeger/tracer.cpp
@@ -1,4 +1,5 @@
#include "tracer.h"
+#include "private.h"
#include <yt/yt/library/tracing/jaeger/model.pb.h>
@@ -37,8 +38,10 @@ using namespace NAuth;
////////////////////////////////////////////////////////////////////////////////
-YT_DEFINE_GLOBAL(const NLogging::TLogger, Logger, "Jaeger");
-YT_DEFINE_GLOBAL(const NProfiling::TProfiler, Profiler, "/tracing");
+static const auto& Logger = JaegerLogger;
+static const auto& Profiler = TracingProfiler;
+
+////////////////////////////////////////////////////////////////////////////////
static const TString ServiceTicketMetadataName = "x-ya-service-ticket";
static const TString TracingServiceAlias = "tracing";
@@ -300,9 +303,7 @@ std::tuple<std::vector<TSharedRef>, int, int> TBatchInfo::PeekQueue(const TJaege
}
TJaegerChannelManager::TJaegerChannelManager()
- : Channel_()
- , ReopenTime_(TInstant::Now())
- , RpcTimeout_()
+ : ReopenTime_(TInstant::Now())
{ }
TJaegerChannelManager::TJaegerChannelManager(
diff --git a/yt/yt/library/tracing/jaeger/tracer.h b/yt/yt/library/tracing/jaeger/tracer.h
index 4bf79315c0..02a71b3cac 100644
--- a/yt/yt/library/tracing/jaeger/tracer.h
+++ b/yt/yt/library/tracing/jaeger/tracer.h
@@ -104,7 +104,7 @@ class TBatchInfo
{
public:
TBatchInfo();
- TBatchInfo(const TString& endpoint);
+ explicit TBatchInfo(const TString& endpoint);
void PopFront();
void EmplaceBack(int size, NYT::TSharedRef&& value);