-
Notifications
You must be signed in to change notification settings - Fork 47
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
Bugfix/metering #517
base: develop
Are you sure you want to change the base?
Bugfix/metering #517
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,6 +202,8 @@ func (s *Tier1Service) Blocks( | |
ctx = reqctx.WithTracer(ctx, s.tracer) | ||
ctx = dmetering.WithBytesMeter(ctx) | ||
ctx = dmetering.WithCounter(ctx, "wasm_input_bytes") | ||
ctx = dmetering.WithCounter(ctx, "live_bytes_uncompressed") | ||
ctx = dmetering.WithCounter(ctx, "stored_bytes_uncompressed") | ||
ctx = reqctx.WithTier2RequestParameters(ctx, s.tier2RequestParameters) | ||
|
||
ctx, span := reqctx.WithSpan(ctx, "substreams/tier1/request") | ||
|
@@ -568,9 +570,26 @@ func (s *Tier1Service) blocks(ctx context.Context, request *pbsubstreamsrpc.Requ | |
streamHandler = pipe | ||
} | ||
|
||
// We need to meter the bytes read from the live stream, as they are not metered by the dstore meters | ||
blockMeteredHandlerFunc := bstream.HandlerFunc(func(blk *pbbstream.Block, obj interface{}) error { | ||
step := obj.(bstream.Stepable).Step() | ||
switch step { | ||
case bstream.StepNewIrreversible: | ||
// already metered by the store in compressed bytes. | ||
// we will meter them here for potential future use | ||
dmetering.GetBytesMeter(ctx).CountInc("uncompressed_bytes_read", len(blk.Payload.GetValue())) | ||
default: | ||
// all other cases are live blocks to be metered | ||
dmetering.GetBytesMeter(ctx).AddBytesRead(len(blk.Payload.GetValue())) | ||
dmetering.GetBytesMeter(ctx).CountInc("uncompressed_live_bytes_read", len(blk.Payload.GetValue())) | ||
} | ||
|
||
return streamHandler.ProcessBlock(blk, obj) | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, donc le tier2 va lire des blocks, et ici c'est la source elle-même qui va être metered, avec des métriques différentes, fack on fera l'aggrégation à la sortie, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the tier2 doesn't play into this. tier2 does not have live blocks and so the blockstream doesn't need to be instrumented. all of the tier2's data sources are dstores which are metered. |
||
blockStream, err := s.streamFactoryFunc( | ||
ctx, | ||
streamHandler, | ||
blockMeteredHandlerFunc, | ||
int64(requestDetails.LinearHandoffBlockNum), | ||
request.StopBlockNum, | ||
cursor, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y'avait-il pas déjà une convention d'avoir l'unité à la fin? donc
uncompressed_read_bytes
plutôt queuncompressed_bytes_read
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, i will make the change