Otel migration (#14424)

* remove opencensus

* gaz

* update dependencies

* add missing dependencies

* fix test?

* Fix note relevance

* add otel http transport middleware

* gaz

* tidy up

* gaz

* changelog

* feedback

* gaz

* fix merge issues
This commit is contained in:
Sammy Rosso
2024-09-12 16:00:20 -07:00
committed by GitHub
parent b5cfd0d35d
commit 170a864239
129 changed files with 416 additions and 415 deletions

View File

@@ -86,7 +86,7 @@ go_library(
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//plugin/ocgrpc:go_default_library",
"@io_opencensus_go//trace:go_default_library",
"@io_opentelemetry_go_otel_trace//:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//credentials:go_default_library",

View File

@@ -32,7 +32,7 @@ func (v *validator) SubmitAggregateAndProof(ctx context.Context, slot primitives
ctx, span := trace.StartSpan(ctx, "validator.SubmitAggregateAndProof")
defer span.End()
span.AddAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
span.SetAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
fmtKey := fmt.Sprintf("%#x", pubKey[:])
duty, err := v.duty(pubKey)

View File

@@ -35,7 +35,7 @@ var failedAttLocalProtectionErr = "attempted to make slashable attestation, reje
func (v *validator) SubmitAttestation(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte) {
ctx, span := trace.StartSpan(ctx, "validator.SubmitAttestation")
defer span.End()
span.AddAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
span.SetAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
v.waitOneThirdOrValidBlock(ctx, slot)
@@ -193,7 +193,7 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot primitives.Slot,
return
}
span.AddAttributes(
span.SetAttributes(
trace.Int64Attribute("slot", int64(slot)), // lint:ignore uintcast -- This conversion is OK for tracing.
trace.StringAttribute("attestationHash", fmt.Sprintf("%#x", attResp.AttestationDataRoot)),
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", data.BeaconBlockRoot)),
@@ -202,9 +202,9 @@ func (v *validator) SubmitAttestation(ctx context.Context, slot primitives.Slot,
trace.StringAttribute("aggregationBitfield", fmt.Sprintf("%#x", aggregationBitfield)),
)
if postElectra {
span.AddAttributes(trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)))
span.SetAttributes(trace.StringAttribute("committeeBitfield", fmt.Sprintf("%#x", committeeBits)))
} else {
span.AddAttributes(trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)))
span.SetAttributes(trace.Int64Attribute("committeeIndex", int64(data.CommitteeIndex)))
}
if v.emitAccountMetrics {

View File

@@ -56,7 +56,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK
defer lock.Unlock()
fmtKey := fmt.Sprintf("%#x", pubKey[:])
span.AddAttributes(trace.StringAttribute("validator", fmtKey))
span.SetAttributes(trace.StringAttribute("validator", fmtKey))
log := log.WithField("pubkey", fmt.Sprintf("%#x", bytesutil.Trunc(pubKey[:])))
// Sign randao reveal, it's used to request block from beacon node
@@ -171,7 +171,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot primitives.Slot, pubK
return
}
span.AddAttributes(
span.SetAttributes(
trace.StringAttribute("blockRoot", fmt.Sprintf("%#x", blkResp.BlockRoot)),
trace.Int64Attribute("numDeposits", int64(len(blk.Block().Body().Deposits()))),
trace.Int64Attribute("numAttestations", int64(len(blk.Block().Body().Attestations()))),
@@ -291,7 +291,7 @@ func ProposeExit(
return errors.Wrap(err, "failed to propose voluntary exit")
}
span.AddAttributes(
span.SetAttributes(
trace.StringAttribute("exitRoot", fmt.Sprintf("%#x", exitResp.ExitRoot)),
)
return nil

View File

@@ -14,10 +14,10 @@ import (
"github.com/prysmaticlabs/prysm/v5/config/params"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
prysmTrace "github.com/prysmaticlabs/prysm/v5/monitoring/tracing/trace"
"github.com/prysmaticlabs/prysm/v5/time/slots"
"github.com/prysmaticlabs/prysm/v5/validator/client/iface"
goTrace "go.opencensus.io/trace"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -66,7 +66,7 @@ func run(ctx context.Context, v iface.Validator) {
log.WithError(err).Fatal("Failed to update proposer settings")
}
for {
ctx, span := trace.StartSpan(ctx, "validator.processSlot")
ctx, span := prysmTrace.StartSpan(ctx, "validator.processSlot")
select {
case <-ctx.Done():
log.Info("Context canceled, stopping validator")
@@ -78,7 +78,7 @@ func run(ctx context.Context, v iface.Validator) {
if !healthTracker.IsHealthy() {
continue
}
span.AddAttributes(trace.Int64Attribute("slot", int64(slot))) // lint:ignore uintcast -- This conversion is OK for tracing.
span.SetAttributes(prysmTrace.Int64Attribute("slot", int64(slot))) // lint:ignore uintcast -- This conversion is OK for tracing.
deadline := v.SlotDeadline(slot)
slotCtx, cancel := context.WithDeadline(ctx, deadline)
@@ -151,7 +151,7 @@ func onAccountsChanged(ctx context.Context, v iface.Validator, current [][48]byt
}
func initializeValidatorAndGetHeadSlot(ctx context.Context, v iface.Validator) (primitives.Slot, error) {
ctx, span := trace.StartSpan(ctx, "validator.initializeValidatorAndGetHeadSlot")
ctx, span := prysmTrace.StartSpan(ctx, "validator.initializeValidatorAndGetHeadSlot")
defer span.End()
ticker := time.NewTicker(backOffPeriod)
@@ -226,7 +226,7 @@ func initializeValidatorAndGetHeadSlot(ctx context.Context, v iface.Validator) (
return headSlot, nil
}
func performRoles(slotCtx context.Context, allRoles map[[48]byte][]iface.ValidatorRole, v iface.Validator, slot primitives.Slot, wg *sync.WaitGroup, span *goTrace.Span) {
func performRoles(slotCtx context.Context, allRoles map[[48]byte][]iface.ValidatorRole, v iface.Validator, slot primitives.Slot, wg *sync.WaitGroup, span trace.Span) {
for pubKey, roles := range allRoles {
wg.Add(len(roles))
for _, role := range roles {

View File

@@ -28,7 +28,7 @@ import (
func (v *validator) SubmitSyncCommitteeMessage(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte) {
ctx, span := trace.StartSpan(ctx, "validator.SubmitSyncCommitteeMessage")
defer span.End()
span.AddAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
span.SetAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
v.waitOneThirdOrValidBlock(ctx, slot)
@@ -98,7 +98,7 @@ func (v *validator) SubmitSyncCommitteeMessage(ctx context.Context, slot primiti
func (v *validator) SubmitSignedContributionAndProof(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte) {
ctx, span := trace.StartSpan(ctx, "validator.SubmitSignedContributionAndProof")
defer span.End()
span.AddAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
span.SetAttributes(trace.StringAttribute("validator", fmt.Sprintf("%#x", pubKey)))
duty, err := v.duty(pubKey)
if err != nil {

View File

@@ -419,7 +419,7 @@ func (s *Store) batchAttestationWrites(ctx context.Context) {
_, span := trace.StartSpan(v.ctx, "batchAttestationWrites.handleBatchedAttestationSaveRequest")
s.batchedAttestations.Append(v.record)
span.AddAttributes(trace.Int64Attribute("num_records", int64(s.batchedAttestations.Len())))
span.SetAttributes(trace.Int64Attribute("num_records", int64(s.batchedAttestations.Len())))
if numRecords := s.batchedAttestations.Len(); numRecords >= attestationBatchCapacity {
log.WithField("recordCount", numRecords).Debug(

View File

@@ -138,7 +138,7 @@ func (client *ApiClient) doRequest(ctx context.Context, httpMethod, fullPath str
var requestDump []byte
ctx, span := trace.StartSpan(ctx, "remote_web3signer.Client.doRequest")
defer span.End()
span.AddAttributes(
span.SetAttributes(
trace.StringAttribute("httpMethod", httpMethod),
trace.StringAttribute("fullPath", fullPath),
trace.BoolAttribute("hasBody", body != nil),

View File

@@ -30,7 +30,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/io/file"
"github.com/prysmaticlabs/prysm/v5/monitoring/backup"
"github.com/prysmaticlabs/prysm/v5/monitoring/prometheus"
tracing2 "github.com/prysmaticlabs/prysm/v5/monitoring/tracing"
"github.com/prysmaticlabs/prysm/v5/monitoring/tracing"
"github.com/prysmaticlabs/prysm/v5/runtime"
"github.com/prysmaticlabs/prysm/v5/runtime/debug"
"github.com/prysmaticlabs/prysm/v5/runtime/prereqs"
@@ -66,7 +66,7 @@ type ValidatorClient struct {
// NewValidatorClient creates a new instance of the Prysm validator client.
func NewValidatorClient(cliCtx *cli.Context) (*ValidatorClient, error) {
// TODO(#9883) - Maybe we can pass in a new validator client config instead of the cliCTX to abstract away the use of flags here .
if err := tracing2.Setup(
if err := tracing.Setup(
"validator", // service name
cliCtx.String(cmd.TracingProcessNameFlag.Name),
cliCtx.String(cmd.TracingEndpointFlag.Name),