Skip to content

Commit d38064f

Browse files
Add tracing spans to GetDuties (#15258)
* Add additional spans for tracing GetDuties * Changelog fragment
1 parent 7f89bb3 commit d38064f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

beacon-chain/core/helpers/beacon_committee.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/OffchainLabs/prysm/v6/crypto/hash"
1919
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
2020
"github.com/OffchainLabs/prysm/v6/math"
21+
"github.com/OffchainLabs/prysm/v6/monitoring/tracing/trace"
2122
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
2223
"github.com/OffchainLabs/prysm/v6/runtime/version"
2324
"github.com/OffchainLabs/prysm/v6/time/slots"
@@ -297,6 +298,9 @@ func verifyAssignmentEpoch(epoch primitives.Epoch, state state.BeaconState) erro
297298
// It verifies the validity of the epoch, then iterates through each slot in the epoch to determine the
298299
// proposer for that slot and assigns them accordingly.
299300
func ProposerAssignments(ctx context.Context, state state.BeaconState, epoch primitives.Epoch) (map[primitives.ValidatorIndex][]primitives.Slot, error) {
301+
ctx, span := trace.StartSpan(ctx, "helpers.ProposerAssignments")
302+
defer span.End()
303+
300304
// Verify if the epoch is valid for assignment based on the provided state.
301305
if err := verifyAssignmentEpoch(epoch, state); err != nil {
302306
return nil, err
@@ -345,6 +349,9 @@ func ProposerAssignments(ctx context.Context, state state.BeaconState, epoch pri
345349
// It retrieves active validator indices, determines the number of committees per slot, and computes
346350
// assignments for each validator based on their presence in the provided validators slice.
347351
func CommitteeAssignments(ctx context.Context, state state.BeaconState, epoch primitives.Epoch, validators []primitives.ValidatorIndex) (map[primitives.ValidatorIndex]*CommitteeAssignment, error) {
352+
ctx, span := trace.StartSpan(ctx, "helpers.CommitteeAssignments")
353+
defer span.End()
354+
348355
// Verify if the epoch is valid for assignment based on the provided state.
349356
if err := verifyAssignmentEpoch(epoch, state); err != nil {
350357
return nil, err

beacon-chain/rpc/prysm/v1alpha1/validator/duties.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/OffchainLabs/prysm/v6/beacon-chain/rpc/core"
1010
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
1111
"github.com/OffchainLabs/prysm/v6/encoding/bytesutil"
12+
"github.com/OffchainLabs/prysm/v6/monitoring/tracing/trace"
1213
ethpb "github.com/OffchainLabs/prysm/v6/proto/prysm/v1alpha1"
1314
"github.com/OffchainLabs/prysm/v6/time/slots"
1415
"google.golang.org/grpc/codes"
@@ -80,9 +81,11 @@ func (vs *Server) duties(ctx context.Context, req *ethpb.DutiesRequest) (*ethpb.
8081
return nil, status.Errorf(codes.Internal, "Could not compute proposer slots: %v", err)
8182
}
8283

84+
ctx, span := trace.StartSpan(ctx, "getDuties.BuildResponse")
85+
defer span.End()
86+
8387
validatorAssignments := make([]*ethpb.DutiesResponse_Duty, 0, len(req.PublicKeys))
8488
nextValidatorAssignments := make([]*ethpb.DutiesResponse_Duty, 0, len(req.PublicKeys))
85-
8689
for _, pubKey := range req.PublicKeys {
8790
if ctx.Err() != nil {
8891
return nil, status.Errorf(codes.Aborted, "Could not continue fetching assignments: %v", ctx.Err())

changelog/pvl-duties-spans.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Added
2+
3+
- Added additional tracing spans for the GetDuties routine

0 commit comments

Comments
 (0)