Skip to content

Commit 7e0a15a

Browse files
authored
Merge 119c2aa into 30a2dc3
2 parents 30a2dc3 + 119c2aa commit 7e0a15a

20 files changed

+168
-68
lines changed

ydb/core/base/blobstorage.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "blobstorage.h"
2+
#include <ydb/library/actors/wilson/wilson_span.h>
23

34
namespace NKikimr {
45

@@ -44,13 +45,37 @@ bool operator<(const TPDiskCategory x, const TPDiskCategory y) {
4445
return std::make_tuple(x.Type(), x.Kind()) < std::make_tuple(y.Type(), y.Kind());
4546
}
4647

48+
void TEvBlobStorage::TEvPut::ToSpan(NWilson::TSpan& span) const {
49+
span
50+
.Attribute("Id", Id.ToString())
51+
.Attribute("PutHandleClass", NKikimrBlobStorage::EPutHandleClass_Name(HandleClass));
52+
}
53+
4754
std::unique_ptr<TEvBlobStorage::TEvPutResult> TEvBlobStorage::TEvPut::MakeErrorResponse(
4855
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId groupId) {
4956
auto res = std::make_unique<TEvPutResult>(status, Id, TStorageStatusFlags(), groupId, 0.0f);
5057
res->ErrorReason = errorReason;
5158
return res;
5259
}
5360

61+
void TEvBlobStorage::TEvGet::ToSpan(NWilson::TSpan& span) const {
62+
NWilson::TArrayValue queries;
63+
queries.reserve(QuerySize);
64+
for (ui32 i = 0; i < QuerySize; ++i) {
65+
const auto& q = Queries[i];
66+
queries.emplace_back(NWilson::TKeyValueList{{
67+
{"Id", q.Id.ToString()},
68+
{"Shift", q.Shift},
69+
{"Size", q.Size},
70+
}});
71+
}
72+
span
73+
.Attribute("Queries", std::move(queries))
74+
.Attribute("GetHandleClass", NKikimrBlobStorage::EGetHandleClass_Name(GetHandleClass))
75+
.Attribute("MustRestoreFirst", MustRestoreFirst)
76+
.Attribute("IsIndexOnly", IsIndexOnly);
77+
}
78+
5479
std::unique_ptr<TEvBlobStorage::TEvGetResult> TEvBlobStorage::TEvGet::MakeErrorResponse(
5580
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId groupId) {
5681
auto res = std::make_unique<TEvGetResult>(status, QuerySize, groupId);
@@ -67,55 +92,119 @@ std::unique_ptr<TEvBlobStorage::TEvGetResult> TEvBlobStorage::TEvGet::MakeErrorR
6792
return res;
6893
}
6994

95+
void TEvBlobStorage::TEvBlock::ToSpan(NWilson::TSpan& span) const {
96+
span
97+
.Attribute("TabletId", ::ToString(TabletId))
98+
.Attribute("Generation", Generation);
99+
}
100+
70101
std::unique_ptr<TEvBlobStorage::TEvBlockResult> TEvBlobStorage::TEvBlock::MakeErrorResponse(
71102
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId /*groupId*/) {
72103
auto res = std::make_unique<TEvBlockResult>(status);
73104
res->ErrorReason = errorReason;
74105
return res;
75106
}
76107

108+
void TEvBlobStorage::TEvPatch::ToSpan(NWilson::TSpan& span) const {
109+
span
110+
.Attribute("OriginalGroupId", OriginalGroupId)
111+
.Attribute("OriginalId", OriginalId.ToString())
112+
.Attribute("PatchedId", PatchedId.ToString());
113+
}
114+
77115
std::unique_ptr<TEvBlobStorage::TEvPatchResult> TEvBlobStorage::TEvPatch::MakeErrorResponse(
78116
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId groupId) {
79117
auto res = std::make_unique<TEvPatchResult>(status, PatchedId, TStorageStatusFlags(), groupId, 0.0f);
80118
res->ErrorReason = errorReason;
81119
return res;
82120
}
83121

122+
void TEvBlobStorage::TEvInplacePatch::ToSpan(NWilson::TSpan& /*span*/) const {
123+
}
124+
84125
std::unique_ptr<TEvBlobStorage::TEvInplacePatchResult> TEvBlobStorage::TEvInplacePatch::MakeErrorResponse(
85126
NKikimrProto::EReplyStatus status, const TString& errorReason) {
86127
auto res = std::make_unique<TEvInplacePatchResult>(status, PatchedId, TStorageStatusFlags(), 0.0f);
87128
res->ErrorReason = errorReason;
88129
return res;
89130
}
90131

132+
void TEvBlobStorage::TEvDiscover::ToSpan(NWilson::TSpan& span) const {
133+
span
134+
.Attribute("TabletId", ::ToString(TabletId))
135+
.Attribute("ReadBody", ReadBody);
136+
}
137+
91138
std::unique_ptr<TEvBlobStorage::TEvDiscoverResult> TEvBlobStorage::TEvDiscover::MakeErrorResponse(
92139
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId/*groupId*/) {
93140
auto res = std::make_unique<TEvDiscoverResult>(status, MinGeneration, 0);
94141
res->ErrorReason = errorReason;
95142
return res;
96143
}
97144

145+
void TEvBlobStorage::TEvRange::ToSpan(NWilson::TSpan& span) const {
146+
span
147+
.Attribute("TabletId", ::ToString(TabletId))
148+
.Attribute("From", From.ToString())
149+
.Attribute("To", To.ToString())
150+
.Attribute("MustRestoreFirst", MustRestoreFirst)
151+
.Attribute("IsIndexOnly", IsIndexOnly);
152+
}
153+
98154
std::unique_ptr<TEvBlobStorage::TEvRangeResult> TEvBlobStorage::TEvRange::MakeErrorResponse(
99155
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId groupId) {
100156
auto res = std::make_unique<TEvRangeResult>(status, From, To, groupId);
101157
res->ErrorReason = errorReason;
102158
return res;
103159
}
104160

161+
void TEvBlobStorage::TEvCollectGarbage::ToSpan(NWilson::TSpan& span) const {
162+
span
163+
.Attribute("TabletId", ::ToString(TabletId))
164+
.Attribute("RecordGeneration", RecordGeneration)
165+
.Attribute("PerGenerationCounter", PerGenerationCounter)
166+
.Attribute("Channel", Channel);
167+
168+
if (Collect) {
169+
span
170+
.Attribute("CollectGeneration", CollectGeneration)
171+
.Attribute("CollectStep", CollectStep);
172+
}
173+
174+
auto vector = [&](const auto& name, const auto& v) {
175+
if (v) {
176+
NWilson::TArrayValue items;
177+
items.reserve(v->size());
178+
for (const TLogoBlobID& id : *v) {
179+
items.emplace_back(id.ToString());
180+
}
181+
span.Attribute(name, std::move(items));
182+
}
183+
};
184+
vector("Keep", Keep);
185+
vector("DoNotKeep", DoNotKeep);
186+
}
187+
105188
std::unique_ptr<TEvBlobStorage::TEvCollectGarbageResult> TEvBlobStorage::TEvCollectGarbage::MakeErrorResponse(
106189
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId /*groupId*/) {
107190
auto res = std::make_unique<TEvCollectGarbageResult>(status, TabletId, RecordGeneration, PerGenerationCounter, Channel);
108191
res->ErrorReason = errorReason;
109192
return res;
110193
}
111194

195+
void TEvBlobStorage::TEvStatus::ToSpan(NWilson::TSpan& /*span*/) const
196+
{}
197+
112198
std::unique_ptr<TEvBlobStorage::TEvStatusResult> TEvBlobStorage::TEvStatus::MakeErrorResponse(
113199
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId /*groupId*/) {
114200
auto res = std::make_unique<TEvStatusResult>(status, TStorageStatusFlags());
115201
res->ErrorReason = errorReason;
116202
return res;
117203
}
118204

205+
void TEvBlobStorage::TEvAssimilate::ToSpan(NWilson::TSpan& /*span*/) const
206+
{}
207+
119208
std::unique_ptr<TEvBlobStorage::TEvAssimilateResult> TEvBlobStorage::TEvAssimilate::MakeErrorResponse(
120209
NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId/*groupId*/) {
121210
return std::make_unique<TEvBlobStorage::TEvAssimilateResult>(status, errorReason);

ydb/core/base/blobstorage.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
#include <optional>
2727

28+
namespace NWilson {
29+
class TSpan;
30+
} // NWilson
31+
2832
namespace NKikimr {
2933

3034
static constexpr ui32 MaxProtobufSize = 67108000;
@@ -993,6 +997,8 @@ struct TEvBlobStorage {
993997
return sizeof(*this) + Buffer.GetSize();
994998
}
995999

1000+
void ToSpan(NWilson::TSpan& span) const;
1001+
9961002
std::unique_ptr<TEvPutResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
9971003
TGroupId groupId);
9981004
};
@@ -1196,6 +1202,8 @@ struct TEvBlobStorage {
11961202
return sizeof(*this) + QuerySize * sizeof(TQuery);
11971203
}
11981204

1205+
void ToSpan(NWilson::TSpan& span) const;
1206+
11991207
std::unique_ptr<TEvGetResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
12001208
TGroupId groupId);
12011209

@@ -1349,6 +1357,8 @@ struct TEvBlobStorage {
13491357
return sizeof(*this);
13501358
}
13511359

1360+
void ToSpan(NWilson::TSpan& span) const;
1361+
13521362
std::unique_ptr<TEvBlockResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
13531363
TGroupId groupId);
13541364
};
@@ -1546,6 +1556,8 @@ struct TEvBlobStorage {
15461556
return sizeof(*this) + sizeof(TDiff) * DiffCount;
15471557
}
15481558

1559+
void ToSpan(NWilson::TSpan& span) const;
1560+
15491561
std::unique_ptr<TEvPatchResult> MakeErrorResponse(NKikimrProto::EReplyStatus status,
15501562
const TString& errorReason, TGroupId groupId);
15511563
};
@@ -1636,6 +1648,8 @@ struct TEvBlobStorage {
16361648
return sizeof(*this) + sizeof(TDiff) * DiffCount;
16371649
}
16381650

1651+
void ToSpan(NWilson::TSpan& span) const;
1652+
16391653
std::unique_ptr<TEvInplacePatchResult> MakeErrorResponse(NKikimrProto::EReplyStatus status,
16401654
const TString& errorReason);
16411655
};
@@ -1723,6 +1737,8 @@ struct TEvBlobStorage {
17231737
return sizeof(*this);
17241738
}
17251739

1740+
void ToSpan(NWilson::TSpan& span) const;
1741+
17261742
std::unique_ptr<TEvDiscoverResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
17271743
TGroupId groupId);
17281744
};
@@ -1828,6 +1844,8 @@ struct TEvBlobStorage {
18281844
return sizeof(*this);
18291845
}
18301846

1847+
void ToSpan(NWilson::TSpan& span) const;
1848+
18311849
std::unique_ptr<TEvRangeResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
18321850
TGroupId groupId);
18331851
};
@@ -2023,6 +2041,8 @@ struct TEvBlobStorage {
20232041
return sizeof(*this) + ((Keep ? Keep->size() : 0) + (DoNotKeep ? DoNotKeep->size() : 0)) * sizeof(TLogoBlobID);
20242042
}
20252043

2044+
void ToSpan(NWilson::TSpan& span) const;
2045+
20262046
std::unique_ptr<TEvCollectGarbageResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
20272047
TGroupId groupId);
20282048
};
@@ -2091,6 +2111,8 @@ struct TEvBlobStorage {
20912111
return sizeof(*this);
20922112
}
20932113

2114+
void ToSpan(NWilson::TSpan& span) const;
2115+
20942116
std::unique_ptr<TEvStatusResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
20952117
TGroupId groupId);
20962118
};
@@ -2166,6 +2188,8 @@ struct TEvBlobStorage {
21662188
return sizeof(*this);
21672189
}
21682190

2191+
void ToSpan(NWilson::TSpan& span) const;
2192+
21692193
std::unique_ptr<TEvAssimilateResult> MakeErrorResponse(NKikimrProto::EReplyStatus status, const TString& errorReason,
21702194
TGroupId groupId);
21712195
};

ydb/core/blobstorage/dsproxy/dsproxy.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,20 @@ class TBlobStorageGroupRequestActor : public TActor<TDerived> {
175175
return NKikimrServices::TActivity::BS_GROUP_REQUEST;
176176
}
177177

178+
template<typename TEv>
178179
TBlobStorageGroupRequestActor(TIntrusivePtr<TBlobStorageGroupInfo> info, TIntrusivePtr<TGroupQueues> groupQueues,
179180
TIntrusivePtr<TBlobStorageGroupProxyMon> mon, const TActorId& source, ui64 cookie,
180181
NKikimrServices::EServiceKikimr logComponent, bool logAccEnabled, TMaybe<TGroupStat::EKind> latencyQueueKind,
181182
TInstant now, TIntrusivePtr<TStoragePoolCounters> &storagePoolCounters, ui32 restartCounter,
182-
NWilson::TSpan&& span, std::shared_ptr<TEvBlobStorage::TExecutionRelay> executionRelay)
183+
NWilson::TTraceId&& traceId, const char *name, const TEv *event,
184+
std::shared_ptr<TEvBlobStorage::TExecutionRelay> executionRelay)
183185
: TActor<TDerived>(&TThis::InitialStateFunc, TDerived::ActorActivityType())
184186
, Info(std::move(info))
185187
, GroupQueues(std::move(groupQueues))
186188
, Mon(std::move(mon))
187189
, PoolCounters(storagePoolCounters)
188190
, LogCtx(logComponent, logAccEnabled)
189-
, Span(std::move(span))
191+
, ParentSpan(TWilson::BlobStorage, std::move(traceId), name)
190192
, RestartCounter(restartCounter)
191193
, CostModel(GroupQueues->CostModel)
192194
, Source(source)
@@ -197,9 +199,16 @@ class TBlobStorageGroupRequestActor : public TActor<TDerived> {
197199
, ExecutionRelay(std::move(executionRelay))
198200
{
199201
TDerived::ActiveCounter(Mon)->Inc();
200-
Span
201-
.Attribute("GroupId", Info->GroupID.GetRawId())
202-
.Attribute("RestartCounter", RestartCounter);
202+
203+
if (ParentSpan) {
204+
const NWilson::TTraceId& parentTraceId = ParentSpan.GetTraceId();
205+
Span = NWilson::TSpan(TWilson::BlobStorage, NWilson::TTraceId::NewTraceId(parentTraceId.GetVerbosity(),
206+
parentTraceId.GetTimeToLive()), ParentSpan.GetName());
207+
ParentSpan.Link(Span.GetTraceId());
208+
Span.Attribute("GroupId", Info->GroupID.GetRawId());
209+
Span.Attribute("RestartCounter", RestartCounter);
210+
event->ToSpan(Span);
211+
}
203212

204213
Y_ABORT_UNLESS(CostModel);
205214
}
@@ -561,8 +570,10 @@ class TBlobStorageGroupRequestActor : public TActor<TDerived> {
561570

562571
if (term) {
563572
if (status == NKikimrProto::OK) {
573+
ParentSpan.EndOk();
564574
Span.EndOk();
565575
} else {
576+
ParentSpan.EndError(errorReason);
566577
Span.EndError(std::move(errorReason));
567578
}
568579
}
@@ -608,6 +619,7 @@ class TBlobStorageGroupRequestActor : public TActor<TDerived> {
608619
TIntrusivePtr<TBlobStorageGroupProxyMon> Mon;
609620
TIntrusivePtr<TStoragePoolCounters> PoolCounters;
610621
TLogContext LogCtx;
622+
NWilson::TSpan ParentSpan;
611623
NWilson::TSpan Span;
612624
TStackVec<std::pair<TDiskResponsivenessTracker::TDiskId, TDuration>, 16> Responsiveness;
613625
TString ErrorReason;

ydb/core/blobstorage/dsproxy/dsproxy_assimilate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class TBlobStorageGroupAssimilateRequest : public TBlobStorageGroupRequestActor<
270270
NWilson::TTraceId traceId, TInstant now, TIntrusivePtr<TStoragePoolCounters>& storagePoolCounters)
271271
: TBlobStorageGroupRequestActor(info, state, mon, source, cookie,
272272
NKikimrServices::BS_PROXY_ASSIMILATE, false, {}, now, storagePoolCounters, ev->RestartCounter,
273-
NWilson::TSpan(TWilson::BlobStorage, std::move(traceId), "DSProxy.Assimilate"), std::move(ev->ExecutionRelay))
273+
std::move(traceId), "DSProxy.Assimilate", ev, std::move(ev->ExecutionRelay))
274274
, SkipBlocksUpTo(ev->SkipBlocksUpTo)
275275
, SkipBarriersUpTo(ev->SkipBarriersUpTo)
276276
, SkipBlobsUpTo(ev->SkipBlobsUpTo)

ydb/core/blobstorage/dsproxy/dsproxy_block.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ class TBlobStorageGroupBlockRequest : public TBlobStorageGroupRequestActor<TBlob
135135
TBlobStorageGroupBlockRequest(const TIntrusivePtr<TBlobStorageGroupInfo> &info,
136136
const TIntrusivePtr<TGroupQueues> &state, const TActorId &source,
137137
const TIntrusivePtr<TBlobStorageGroupProxyMon> &mon, TEvBlobStorage::TEvBlock *ev,
138-
ui64 cookie, NWilson::TSpan&& span, TInstant now,
138+
ui64 cookie, NWilson::TTraceId&& traceId, TInstant now,
139139
TIntrusivePtr<TStoragePoolCounters> &storagePoolCounters)
140140
: TBlobStorageGroupRequestActor(info, state, mon, source, cookie,
141141
NKikimrServices::BS_PROXY_BLOCK, false, {}, now, storagePoolCounters, ev->RestartCounter,
142-
std::move(span), std::move(ev->ExecutionRelay))
142+
std::move(traceId), "DSProxy.Block", ev, std::move(ev->ExecutionRelay))
143143
, TabletId(ev->TabletId)
144144
, Generation(ev->Generation)
145145
, Deadline(ev->Deadline)
@@ -179,12 +179,7 @@ IActor* CreateBlobStorageGroupBlockRequest(const TIntrusivePtr<TBlobStorageGroup
179179
const TIntrusivePtr<TGroupQueues> &state, const TActorId &source,
180180
const TIntrusivePtr<TBlobStorageGroupProxyMon> &mon, TEvBlobStorage::TEvBlock *ev,
181181
ui64 cookie, NWilson::TTraceId traceId, TInstant now, TIntrusivePtr<TStoragePoolCounters> &storagePoolCounters) {
182-
NWilson::TSpan span(TWilson::BlobStorage, std::move(traceId), "DSProxy.Block");
183-
if (span) {
184-
span.Attribute("event", ev->ToString());
185-
}
186-
187-
return new TBlobStorageGroupBlockRequest(info, state, source, mon, ev, cookie, std::move(span), now, storagePoolCounters);
182+
return new TBlobStorageGroupBlockRequest(info, state, source, mon, ev, cookie, std::move(traceId), now, storagePoolCounters);
188183
}
189184

190185
} // NKikimr

ydb/core/blobstorage/dsproxy/dsproxy_collect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class TBlobStorageGroupCollectGarbageRequest : public TBlobStorageGroupRequestAc
147147
NWilson::TTraceId traceId, TInstant now, TIntrusivePtr<TStoragePoolCounters> &storagePoolCounters)
148148
: TBlobStorageGroupRequestActor(info, state, mon, source, cookie,
149149
NKikimrServices::BS_PROXY_COLLECT, false, {}, now, storagePoolCounters, ev->RestartCounter,
150-
NWilson::TSpan(TWilson::BlobStorage, std::move(traceId), "DSProxy.CollectGarbage"), std::move(ev->ExecutionRelay))
150+
std::move(traceId), "DSProxy.CollectGarbage", ev, std::move(ev->ExecutionRelay))
151151
, TabletId(ev->TabletId)
152152
, RecordGeneration(ev->RecordGeneration)
153153
, PerGenerationCounter(ev->PerGenerationCounter)

ydb/core/blobstorage/dsproxy/dsproxy_discover.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,7 @@ class TBlobStorageGroupDiscoverRequest : public TBlobStorageGroupRequestActor<TB
884884
TIntrusivePtr<TStoragePoolCounters> &storagePoolCounters)
885885
: TBlobStorageGroupRequestActor(info, state, mon, source, cookie,
886886
NKikimrServices::BS_PROXY_DISCOVER, true, {}, now, storagePoolCounters, ev->RestartCounter,
887-
NWilson::TSpan(TWilson::BlobStorage, std::move(traceId), "DSProxy.Discover"),
888-
std::move(ev->ExecutionRelay))
887+
std::move(traceId), "DSProxy.Discover", ev, std::move(ev->ExecutionRelay))
889888
, TabletId(ev->TabletId)
890889
, MinGeneration(ev->MinGeneration)
891890
, ReadBody(ev->ReadBody)

ydb/core/blobstorage/dsproxy/dsproxy_discover_m3dc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ class TBlobStorageGroupMirror3dcDiscoverRequest : public TBlobStorageGroupReques
464464
TIntrusivePtr<TStoragePoolCounters> &storagePoolCounters)
465465
: TBlobStorageGroupRequestActor(std::move(info), std::move(state), std::move(mon), source, cookie,
466466
NKikimrServices::BS_PROXY_DISCOVER, false, {}, now, storagePoolCounters, ev->RestartCounter,
467-
NWilson::TSpan(TWilson::BlobStorage, std::move(traceId), "DSProxy.Discover(mirror-3-dc)"),
468-
std::move(ev->ExecutionRelay))
467+
std::move(traceId), "DSProxy.Discover", ev, std::move(ev->ExecutionRelay))
469468
, TabletId(ev->TabletId)
470469
, MinGeneration(ev->MinGeneration)
471470
, StartTime(now)

0 commit comments

Comments
 (0)