mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-23 15:10:34 +00:00
removed head sampling ratio from config
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
This commit is contained in:
@@ -42,23 +42,27 @@
|
||||
|
||||
Usage examples:
|
||||
|
||||
Span names and attribute keys come from per-module `*SpanNames.h`
|
||||
headers (e.g. RpcSpanNames.h, TxSpanNames.h) as typed compile-time
|
||||
constants — never raw string literals — so the naming spec is
|
||||
enforced at the call site and dashboards stay in sync.
|
||||
|
||||
1. Basic RPC tracing (factory method with category):
|
||||
@code
|
||||
// Define prefix at class level:
|
||||
static constexpr std::string_view spanPrefix_ = "rpc.command";
|
||||
#include <xrpld/rpc/detail/RpcSpanNames.h>
|
||||
using namespace xrpl::telemetry;
|
||||
|
||||
// At the call site:
|
||||
auto span = SpanGuard::span(
|
||||
TraceCategory::Rpc, spanPrefix_, "submit");
|
||||
span.setAttribute("xrpl.rpc.command", "submit");
|
||||
span.setAttribute("xrpl.rpc.status", "success");
|
||||
TraceCategory::Rpc, rpc_span::prefix::command, "submit");
|
||||
span.setAttribute(rpc_span::attr::command, "submit");
|
||||
span.setAttribute(rpc_span::attr::rpcStatus, rpc_span::val::success);
|
||||
// span ended automatically on scope exit
|
||||
@endcode
|
||||
|
||||
2. Error recording:
|
||||
@code
|
||||
auto span = SpanGuard::span(
|
||||
TraceCategory::Rpc, "rpc.command", "submit");
|
||||
TraceCategory::Rpc, rpc_span::prefix::command, "submit");
|
||||
try {
|
||||
doWork();
|
||||
span.setOk();
|
||||
@@ -69,29 +73,32 @@
|
||||
|
||||
3. Cross-thread context propagation:
|
||||
@code
|
||||
#include <xrpld/consensus/ConsensusSpanNames.h>
|
||||
using namespace xrpl::telemetry;
|
||||
|
||||
// Thread A: create span and capture context
|
||||
auto span = SpanGuard::span(
|
||||
TraceCategory::Consensus, "consensus", "round");
|
||||
TraceCategory::Consensus, seg::consensus, consensus::span::op::round);
|
||||
auto ctx = span.captureContext();
|
||||
|
||||
// Thread B: create child with captured context
|
||||
auto child = SpanGuard::childSpan("consensus.accept", ctx);
|
||||
auto child = SpanGuard::childSpan(consensus::span::accept, ctx);
|
||||
@endcode
|
||||
|
||||
4. Conditional check (rarely needed — methods are no-ops on null):
|
||||
@code
|
||||
auto span = SpanGuard::span(
|
||||
TraceCategory::Rpc, "rpc", "request");
|
||||
TraceCategory::Rpc, rpc_span::prefix::rpc, rpc_span::op::httpRequest);
|
||||
if (span) {
|
||||
// expensive attribute computation only when active
|
||||
span.setAttribute("xrpl.rpc.payload_size", computeSize());
|
||||
span.setAttribute(rpc_span::attr::requestPayloadSize, computeSize());
|
||||
}
|
||||
@endcode
|
||||
|
||||
5. Tail-based filtering via discard():
|
||||
@code
|
||||
auto span = SpanGuard::span(
|
||||
TraceCategory::Transactions, "tx", "process");
|
||||
TraceCategory::Transactions, tx_span::prefix::tx, tx_span::op::process);
|
||||
auto result = preflight(tx);
|
||||
if (result != tesSUCCESS) {
|
||||
span.discard(); // drop span, never exported
|
||||
|
||||
@@ -150,13 +150,16 @@ public:
|
||||
/** Path to a CA certificate bundle for TLS verification. */
|
||||
std::string tlsCertPath;
|
||||
|
||||
/** Head-based sampling ratio in [0.0, 1.0]. 1.0 = trace everything.
|
||||
This is a head-based (pre-decision) sampler using
|
||||
TraceIdRatioBasedSampler — the decision to record or drop a
|
||||
trace is made before the root span starts. For post-hoc
|
||||
(tail-based) filtering, see SpanGuard::discard().
|
||||
/** Head-based sampling ratio. Intentionally fixed at 1.0 (sample
|
||||
everything) and NOT read from config. A per-node ratio would let
|
||||
nodes make divergent keep/drop decisions for the same distributed
|
||||
trace, producing broken/partial traces. The ratio sampler is wrapped
|
||||
in a ParentBasedSampler (see Telemetry.cpp) so spans inheriting a
|
||||
remote parent honor the upstream sampled flag. Volume reduction is
|
||||
delegated to the collector's tail sampling; for node-local post-hoc
|
||||
dropping see SpanGuard::discard().
|
||||
*/
|
||||
double samplingRatio = 1.0;
|
||||
double const samplingRatio = 1.0;
|
||||
|
||||
/** Maximum number of spans per batch export. */
|
||||
std::uint32_t batchSize = 512;
|
||||
|
||||
Reference in New Issue
Block a user