diff options
author | pechatnov <pechatnov@yandex-team.com> | 2023-11-20 18:25:58 +0300 |
---|---|---|
committer | pechatnov <pechatnov@yandex-team.com> | 2023-11-20 21:11:11 +0300 |
commit | 117d358ebbfad65fc6165b94166e4b1de7fb047d (patch) | |
tree | 4558cb31c49cd30e3d55c8adc7d08a32d02904a0 | |
parent | a121153fbb5342a7b25b1f3e46af26ba7fca2d96 (diff) | |
download | ydb-117d358ebbfad65fc6165b94166e4b1de7fb047d.tar.gz |
YT-20504: Add path/paths tags to trace contexts of client rpc requests
Выглядит вот так теперь
![](https://arcanum.s3.mds.yandex.net/files/pechatnov/WJJlOtTWaxA18XHOXw8WG)
-rw-r--r-- | yt/yt/client/api/rpc_proxy/client_base.cpp | 15 | ||||
-rw-r--r-- | yt/yt/core/rpc/client.cpp | 3 | ||||
-rw-r--r-- | yt/yt/core/rpc/client.h | 2 | ||||
-rw-r--r-- | yt/yt/core/tracing/trace_context.cpp | 6 | ||||
-rw-r--r-- | yt/yt/core/tracing/trace_context.h | 2 |
5 files changed, 28 insertions, 0 deletions
diff --git a/yt/yt/client/api/rpc_proxy/client_base.cpp b/yt/yt/client/api/rpc_proxy/client_base.cpp index 033ecfcafb..583a843287 100644 --- a/yt/yt/client/api/rpc_proxy/client_base.cpp +++ b/yt/yt/client/api/rpc_proxy/client_base.cpp @@ -764,6 +764,9 @@ TFuture<TUnversionedLookupRowsResult> TClientBase::LookupRows( req->SetTimeout(options.Timeout.value_or(GetRpcProxyConnection()->GetConfig()->DefaultLookupRowsTimeout)); req->set_path(path); + if (NTracing::IsCurrentTraceContextRecorded()) { + req->TracingTags().push_back({"yt.table_path", path}); + } req->Attachments() = SerializeRowset(nameTable, keys, req->mutable_rowset_descriptor()); if (!options.ColumnFilter.IsUniversal()) { @@ -808,6 +811,9 @@ TFuture<TVersionedLookupRowsResult> TClientBase::VersionedLookupRows( req->SetTimeout(options.Timeout.value_or(GetRpcProxyConnection()->GetConfig()->DefaultLookupRowsTimeout)); req->set_path(path); + if (NTracing::IsCurrentTraceContextRecorded()) { + req->TracingTags().push_back({"yt.table_path", path}); + } req->Attachments() = SerializeRowset(nameTable, keys, req->mutable_rowset_descriptor()); if (!options.ColumnFilter.IsUniversal()) { @@ -875,6 +881,15 @@ TFuture<std::vector<TUnversionedLookupRowsResult>> TClientBase::MultiLookup( req->Attachments().insert(req->Attachments().end(), rowset.begin(), rowset.end()); } + if (NTracing::IsCurrentTraceContextRecorded()) { + std::vector<TString> paths; + paths.reserve(subrequests.size()); + for (const auto& subrequest : subrequests) { + paths.push_back(subrequest.Path); + } + req->TracingTags().push_back({"yt.table_paths", NYson::ConvertToYsonString(paths).ToString()}); + } + req->set_replica_consistency(static_cast<NProto::EReplicaConsistency>(options.ReplicaConsistency)); req->set_timestamp(options.Timestamp); req->set_retention_timestamp(options.RetentionTimestamp); diff --git a/yt/yt/core/rpc/client.cpp b/yt/yt/core/rpc/client.cpp index fb20e7a2f3..107148dd50 100644 --- a/yt/yt/core/rpc/client.cpp +++ b/yt/yt/core/rpc/client.cpp @@ -426,6 +426,9 @@ void TClientRequest::TraceRequest(const NTracing::TTraceContextPtr& traceContext { traceContext->AddTag(RequestIdAnnotation, GetRequestId()); traceContext->AddTag(EndpointAnnotation, Channel_->GetEndpointDescription()); + for (const auto& [tagKey, tagValue] : TracingTags_) { + traceContext->AddTag(tagKey, tagValue); + } } void TClientRequest::PrepareHeader() diff --git a/yt/yt/core/rpc/client.h b/yt/yt/core/rpc/client.h index d8d070e7b4..05d1c30495 100644 --- a/yt/yt/core/rpc/client.h +++ b/yt/yt/core/rpc/client.h @@ -138,6 +138,8 @@ public: DEFINE_BYVAL_RW_PROPERTY(bool, EnableLegacyRpcCodecs, true); DEFINE_BYVAL_RW_PROPERTY(bool, GenerateAttachmentChecksums, true); DEFINE_BYVAL_RW_PROPERTY(IMemoryReferenceTrackerPtr, MemoryReferenceTracker); + // Field is used on client side only. So it is never serialized. + DEFINE_BYREF_RW_PROPERTY(NTracing::TTraceContext::TTagList, TracingTags); // For testing purposes only. DEFINE_BYVAL_RW_PROPERTY(std::optional<TDuration>, SendDelay); diff --git a/yt/yt/core/tracing/trace_context.cpp b/yt/yt/core/tracing/trace_context.cpp index b4d1a2db67..7712c0b8da 100644 --- a/yt/yt/core/tracing/trace_context.cpp +++ b/yt/yt/core/tracing/trace_context.cpp @@ -721,6 +721,12 @@ void FlushCurrentTraceContextElapsedTime() NDetail::TraceContextTimingCheckpoint = now; } +bool IsCurrentTraceContextRecorded() +{ + auto* context = TryGetCurrentTraceContext(); + return context && context->IsRecorded(); +} + //! Do not rename, change the signature, or drop Y_NO_INLINE. //! Used in devtools/gdb/yt_fibers_printer.py. Y_NO_INLINE TTraceContext* TryGetTraceContextFromPropagatingStorage(const NConcurrency::TPropagatingStorage& storage) diff --git a/yt/yt/core/tracing/trace_context.h b/yt/yt/core/tracing/trace_context.h index 3f8ef8641a..cad13020ef 100644 --- a/yt/yt/core/tracing/trace_context.h +++ b/yt/yt/core/tracing/trace_context.h @@ -390,6 +390,8 @@ private: //////////////////////////////////////////////////////////////////////////////// +bool IsCurrentTraceContextRecorded(); + template <class TFn> void AnnotateTraceContext(TFn&& fn); |