Skip to content

Add traceparent to TRequestSettings #326 #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/ydb-cpp-sdk/client/types/request_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <vector>
#include <utility>
#include <string>

namespace NYdb::inline V3 {

Expand All @@ -20,6 +21,7 @@ struct TRequestSettings {
FLUENT_SETTING(std::string, RequestType);
FLUENT_SETTING(THeader, Header);
FLUENT_SETTING(TDuration, ClientTimeout);
FLUENT_SETTING(std::string, TraceParent);

TRequestSettings() = default;

Expand All @@ -29,6 +31,7 @@ struct TRequestSettings {
, RequestType_(other.RequestType_)
, Header_(other.Header_)
, ClientTimeout_(other.ClientTimeout_)
, TraceParent_(other.TraceParent)
{}
};

Expand Down
5 changes: 5 additions & 0 deletions src/client/impl/ydb_internal/rpc_request_settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ struct TRpcRequestSettings {
rpcSettings.TraceId = settings.TraceId_;
rpcSettings.RequestType = settings.RequestType_;
rpcSettings.Header = settings.Header_;

if (!settings.TraceParent_.empty()) {
rpcSettings.Header.emplace_back("traceparent", settings.TraceParent_);
Copy link
Collaborator

@Gazizonoki Gazizonoki Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

На будущее, лучше traceparent сразу до инициализации Aux прокидывать (в grpc_connections.h).
Смысл такой - нам хочется в grpc_connections.h тоже собирать спаны, удобно, если там будет TraceParent отдельным параметром.
Пока можно так замержить, но в будущем стоит поправить.

}

rpcSettings.PreferredEndpoint = preferredEndpoint;
rpcSettings.EndpointPolicy = endpointPolicy;
rpcSettings.UseAuth = true;
Expand Down
Loading