Skip to content

Commit

Permalink
Renamed several tracing parameters (ydb-platform#2134)
Browse files Browse the repository at this point in the history
  • Loading branch information
domwst committed Mar 19, 2024
1 parent b17ff7a commit 94c3785
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 49 deletions.
36 changes: 18 additions & 18 deletions ydb/core/cms/console/jaeger_tracing_configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
<< samplingRule.ShortDebugString() << ". Skipping the rule");
continue;
}
if (!samplingRule.HasLevel() || !samplingRule.HasFraction() || !samplingRule.HasMaxRatePerMinute()) {
if (!samplingRule.HasLevel() || !samplingRule.HasFraction() || !samplingRule.HasMaxTracesPerMinute()) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "missing required fields in rule " << samplingRule.ShortDebugString()
<< " (required fields are: level, fraction, max_rate_per_minute). Skipping the rule");
<< " (required fields are: level, fraction, max_traces_per_minute). Skipping the rule");
continue;
}
if (samplingRule.GetMaxRatePerMinute() == 0) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "max_rate_per_minute should never be zero. Found in rule " << samplingRule.GetMaxRatePerMinute()
if (samplingRule.GetMaxTracesPerMinute() == 0) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "max_traces_per_minute should never be zero. Found in rule " << samplingRule.GetMaxTracesPerMinute()
<< ". Skipping the rule");
continue;
}
Expand All @@ -125,8 +125,8 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
.Level = static_cast<ui8>(level),
.Sampler = fraction,
.Throttler = TThrottlingSettings {
.MaxRatePerMinute = samplingRule.GetMaxRatePerMinute(),
.MaxBurst = samplingRule.GetMaxBurst(),
.MaxTracesPerMinute = samplingRule.GetMaxTracesPerMinute(),
.MaxTracesBurst = samplingRule.GetMaxTracesBurst(),
},
};
settings.SamplingRules[static_cast<size_t>(requestType)].push_back(rule);
Expand All @@ -142,31 +142,31 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
continue;
}

if (!throttlingRule.HasMaxRatePerMinute()) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "missing required field max_rate_per_minute in rule "
if (!throttlingRule.HasMaxTracesPerMinute()) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "missing required field max_traces_per_minute in rule "
<< throttlingRule.ShortDebugString() << ". Skipping the rule");
continue;
}
if (throttlingRule.GetMaxRatePerMinute() == 0) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "max_rate_per_minute should never be zero. Found in rule " << throttlingRule.GetMaxRatePerMinute()
if (throttlingRule.GetMaxTracesPerMinute() == 0) {
ALOG_ERROR(NKikimrServices::CMS_CONFIGS, "max_traces_per_minute should never be zero. Found in rule " << throttlingRule.GetMaxTracesPerMinute()
<< ". Skipping the rule");
continue;
}

ui64 maxRatePerMinute = throttlingRule.GetMaxRatePerMinute();
ui64 maxBurst = throttlingRule.GetMaxBurst();
ui64 maxRatePerMinute = throttlingRule.GetMaxTracesPerMinute();
ui64 maxBurst = throttlingRule.GetMaxTracesBurst();
TExternalThrottlingRule<TThrottlingSettings> rule {
.Throttler = TThrottlingSettings {
.MaxRatePerMinute = maxRatePerMinute,
.MaxBurst = maxBurst,
.MaxTracesPerMinute = maxRatePerMinute,
.MaxTracesBurst = maxBurst,
},
};
auto& currentRule = settings.ExternalThrottlingRules[static_cast<size_t>(requestType)];
if (currentRule) {
ALOG_WARN(NKikimrServices::CMS_CONFIGS, "duplicate external throttling rule for scope "
<< throttlingRule.GetScope() << ". Adding the limits");
currentRule->Throttler.MaxBurst += rule.Throttler.MaxBurst;
currentRule->Throttler.MaxRatePerMinute += rule.Throttler.MaxRatePerMinute;
currentRule->Throttler.MaxTracesBurst += rule.Throttler.MaxTracesBurst;
currentRule->Throttler.MaxTracesPerMinute += rule.Throttler.MaxTracesPerMinute;
} else {
currentRule = rule;
}
Expand All @@ -176,8 +176,8 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
if (cfg.GetExternalThrottling().empty()){
TExternalThrottlingRule<TThrottlingSettings> rule {
.Throttler = TThrottlingSettings {
.MaxRatePerMinute = Max<ui64>(),
.MaxBurst = 0,
.MaxTracesPerMinute = Max<ui64>(),
.MaxTracesBurst = 0,
},
};

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/driver_lib/run/kikimr_services_initializers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ void TBasicServicesInitializer::InitializeServices(NActors::TActorSystemSetup* s
uploaderParams.field = uploaderConfig.Get##field(); \
}

GET_FIELD_FROM_CONFIG(MaxSpansPerSecond)
GET_FIELD_FROM_CONFIG(MaxExportedSpansPerSecond)
GET_FIELD_FROM_CONFIG(MaxSpansInBatch)
GET_FIELD_FROM_CONFIG(MaxBytesInBatch)
GET_FIELD_FROM_CONFIG(SpanExportTimeoutSeconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void TSamplingThrottlingConfigurator::UpdateSettings(TSettings<double, TThrottli
TSettings<double, TIntrusivePtr<TThrottler>> TSamplingThrottlingConfigurator::GenerateThrottlers(
TSettings<double, TThrottlingSettings> settings) {
return settings.MapThrottler([this](const TThrottlingSettings& settings) {
return MakeIntrusive<TThrottler>(settings.MaxRatePerMinute, settings.MaxBurst, TimeProvider);
return MakeIntrusive<TThrottler>(settings.MaxTracesPerMinute, settings.MaxTracesBurst, TimeProvider);
});
}

Expand Down
4 changes: 2 additions & 2 deletions ydb/core/jaeger_tracing/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace NKikimr::NJaegerTracing {

struct TThrottlingSettings {
ui64 MaxRatePerMinute;
ui64 MaxBurst;
ui64 MaxTracesPerMinute;
ui64 MaxTracesBurst;
};

template<class TSampling, class TThrottling>
Expand Down
8 changes: 4 additions & 4 deletions ydb/core/jaeger_tracing/throttler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
namespace NKikimr::NJaegerTracing {

TThrottler::TThrottler(ui64 maxRatePerMinute, ui64 maxBurst, TIntrusivePtr<ITimeProvider> timeProvider)
: MaxRatePerMinute(maxRatePerMinute)
, MaxBurst(maxBurst + 1)
, BetweenSends(TDuration::Minutes(1).MicroSeconds() / MaxRatePerMinute)
: MaxTracesPerMinute(maxRatePerMinute)
, MaxTracesBurst(maxBurst + 1)
, BetweenSends(TDuration::Minutes(1).MicroSeconds() / MaxTracesPerMinute)
, TimeProvider(std::move(timeProvider))
, EffectiveTs(TimeProvider->Now().MicroSeconds())
{}

bool TThrottler::Throttle() {
auto now = TimeProvider->Now().MicroSeconds();
auto ts = EffectiveTs.load(std::memory_order_relaxed);
auto maxFinalTs = ClampAdd(now, ClampMultiply(BetweenSends, MaxBurst));
auto maxFinalTs = ClampAdd(now, ClampMultiply(BetweenSends, MaxTracesBurst));
while (true) {
if (ts < now) {
if (EffectiveTs.compare_exchange_weak(ts, now + BetweenSends, std::memory_order_relaxed)) {
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/jaeger_tracing/throttler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class TThrottler: public TThrRefBase {
static ui64 ClampAdd(ui64 a, ui64 b);
static ui64 ClampMultiply(ui64 a, ui64 b);

const ui64 MaxRatePerMinute;
const ui64 MaxBurst;
const ui64 MaxTracesPerMinute;
const ui64 MaxTracesBurst;
const ui64 BetweenSends;
TIntrusivePtr<ITimeProvider> TimeProvider;
std::atomic<ui64> EffectiveTs;
Expand Down
10 changes: 5 additions & 5 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1603,21 +1603,21 @@ message TTracingConfig {
// detalisation of traces sampled by this rule
optional uint32 Level = 3;
// maximum average amount of traces sampled by this rule
optional uint64 MaxRatePerMinute = 4;
optional uint64 MaxTracesPerMinute = 4;
// maximum burst of traces sampled by this rule
optional uint64 MaxBurst = 5;
optional uint64 MaxTracesBurst = 5;
}

// field meaning is the same as in TSamplingScope
message TExternalThrottlingScope {
optional TSelectors Scope = 1;
optional uint64 MaxRatePerMinute = 2;
optional uint64 MaxBurst = 3;
optional uint64 MaxTracesPerMinute = 2;
optional uint64 MaxTracesBurst = 3;
}

message TUploaderConfig {
// maximum average amount of spans uploaded from the node
optional uint64 MaxSpansPerSecond = 1;
optional uint64 MaxExportedSpansPerSecond = 1;
// maximum batch size in spans
optional uint64 MaxSpansInBatch = 2;
// maximum batch size in bytes
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/actors/wilson/wilson_uploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace NWilson {

public:
TWilsonUploader(WilsonUploaderParams params)
: MaxSpansPerSecond(params.MaxSpansPerSecond)
: MaxSpansPerSecond(params.MaxExportedSpansPerSecond)
, MaxSpansInBatch(params.MaxSpansInBatch)
, MaxBytesInBatch(params.MaxBytesInBatch)
, MaxBatchAccumulation(params.MaxBatchAccumulation)
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/actors/wilson/wilson_uploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace NWilson {
TString ServiceName;
std::unique_ptr<IGrpcSigner> GrpcSigner;

ui64 MaxSpansPerSecond = Max<ui64>();
ui64 MaxExportedSpansPerSecond = Max<ui64>();
ui64 MaxSpansInBatch = 150;
ui64 MaxBytesInBatch = 20'000'000;
ui64 MaxBatchAccumulationMilliseconds = 1'000;
Expand Down
14 changes: 7 additions & 7 deletions ydb/tools/cfg/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,17 +1136,17 @@ def get_sampling_scope(sampling):
sampling_scope_pb.Scope.CopyFrom(get_selectors(selectors))
sampling_scope_pb.Fraction = sampling['fraction']
sampling_scope_pb.Level = sampling['level']
sampling_scope_pb.MaxRatePerMinute = sampling['max_rate_per_minute']
sampling_scope_pb.MaxBurst = sampling.get('max_burst', 0)
sampling_scope_pb.MaxTracesPerMinute = sampling['max_traces_per_minute']
sampling_scope_pb.MaxTracesBurst = sampling.get('max_traces_burst', 0)
return sampling_scope_pb

def get_external_throttling(throttling):
throttling_scope_pb = config_pb2.TTracingConfig.TExternalThrottlingScope()
selectors = throttling.get("scope")
if selectors is not None:
throttling_scope_pb.Scope.CopyFrom(get_selectors(selectors))
throttling_scope_pb.MaxRatePerMinute = throttling['max_rate_per_minute']
throttling_scope_pb.MaxBurst = throttling.get('max_burst', 0)
throttling_scope_pb.MaxTracesPerMinute = throttling['max_traces_per_minute']
throttling_scope_pb.MaxTracesBurst = throttling.get('max_traces_burst', 0)
return throttling_scope_pb

def get_auth_config(auth):
Expand Down Expand Up @@ -1195,9 +1195,9 @@ def get_backend(backend):
def get_uploader(uploader):
uploader_pb = config_pb2.TTracingConfig.TUploaderConfig()

max_spans_per_second = uploader.get("max_spans_per_second")
if max_spans_per_second is not None:
uploader_pb.MaxSpansPerSecond = max_spans_per_second
max_exported_spans_per_second = uploader.get("max_exported_spans_per_second")
if max_exported_spans_per_second is not None:
uploader_pb.MaxExportedSpansPerSecond = max_exported_spans_per_second

max_spans_in_batch = uploader.get("max_spans_in_batch")
if max_spans_in_batch is not None:
Expand Down
14 changes: 7 additions & 7 deletions ydb/tools/cfg/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
uploader=dict(
type="object",
properties=dict(
max_spans_per_second=dict(type="integer", minimum=1),
max_exported_spans_per_second=dict(type="integer", minimum=1),
max_spans_in_batch=dict(type="integer", minimum=1),
max_bytes_in_batch=dict(type="integer"),
max_batch_accumulation_milliseconds=dict(type="integer"),
Expand All @@ -191,10 +191,10 @@
scope=SELECTORS_CONFIGS,
fraction=dict(type="number", minimum=0, maximum=1),
level=dict(type="integer", minimum=0, maximum=15),
max_rate_per_minute=dict(type="integer", minimum=0),
max_burst=dict(type="integer", minimum=0),
max_traces_per_minute=dict(type="integer", minimum=0),
max_traces_burst=dict(type="integer", minimum=0),
),
required=["fraction", "level", "max_rate_per_minute"],
required=["fraction", "level", "max_traces_per_minute"],
),
),
external_throttling=dict(
Expand All @@ -203,10 +203,10 @@
type="object",
properties=dict(
scope=SELECTORS_CONFIGS,
max_rate_per_minute=dict(type="integer", minimum=0),
max_burst=dict(type="integer", minimum=0),
max_traces_per_minute=dict(type="integer", minimum=0),
max_traces_burst=dict(type="integer", minimum=0),
),
required=["max_rate_per_minute"],
required=["max_traces_per_minute"],
),
),
),
Expand Down

0 comments on commit 94c3785

Please sign in to comment.