Skip to content

Commit 8918b0f

Browse files
authored
Use user provided otel header to start grpc proxy tracing. (#628)
1 parent e98bcbc commit 8918b0f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

ydb/core/grpc_services/base/base.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,7 @@ class TRefreshTokenImpl
534534
}
535535

536536
const TMaybe<TString> GetPeerMetaValues(const TString&) const override {
537-
Y_ABORT("Unimplemented");
538-
return TMaybe<TString>{};
537+
return {};
539538
}
540539

541540
TVector<TStringBuf> FindClientCert() const override {

ydb/core/grpc_services/grpc_request_proxy.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class TGRpcRequestProxyImpl
151151
}
152152

153153

154-
//StartTracing(*requestBaseCtx);
154+
StartTracing(*requestBaseCtx);
155155

156156
if (IsAuthStateOK(*requestBaseCtx)) {
157157
Handle(event, ctx);
@@ -410,9 +410,12 @@ bool TGRpcRequestProxyImpl::IsAuthStateOK(const IRequestProxyCtx& ctx) {
410410
}
411411

412412
void TGRpcRequestProxyImpl::StartTracing(IRequestProxyCtx& ctx) {
413-
auto traceId = NWilson::TTraceId::NewTraceId(15, Max<ui32>());
414-
NWilson::TSpan grpcRequestProxySpan(TWilsonGrpc::RequestProxy, std::move(traceId), "GrpcRequestProxy");
415-
ctx.StartTracing(std::move(grpcRequestProxySpan));
413+
if (const auto otelHeader = ctx.GetPeerMetaValues(NYdb::OTEL_TRACE_HEADER)) {
414+
if (auto traceId = NWilson::TTraceId::FromTraceparentHeader(otelHeader.GetRef())) {
415+
NWilson::TSpan grpcRequestProxySpan(TWilsonGrpc::RequestProxy, std::move(traceId), "GrpcRequestProxy");
416+
ctx.StartTracing(std::move(grpcRequestProxySpan));
417+
}
418+
}
416419
}
417420

418421
void TGRpcRequestProxyImpl::HandleSchemeBoard(TSchemeBoardEvents::TEvNotifyUpdate::TPtr& ev, const TActorContext& ctx) {

0 commit comments

Comments
 (0)