mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 09:14:28 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Package tracing sets up jaeger as an opentracing tool
|
|
// for services in Prysm.
|
|
package tracing
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"contrib.go.opencensus.io/exporter/jaeger"
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
|
"github.com/sirupsen/logrus"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
var log = logrus.WithField("prefix", "tracing")
|
|
|
|
// Setup creates and initializes a new tracing configuration..
|
|
func Setup(serviceName, processName, endpoint string, sampleFraction float64, enable bool) error {
|
|
if !enable {
|
|
trace.ApplyConfig(trace.Config{DefaultSampler: trace.NeverSample()})
|
|
return nil
|
|
}
|
|
|
|
if serviceName == "" {
|
|
return errors.New("tracing service name cannot be empty")
|
|
}
|
|
|
|
trace.ApplyConfig(trace.Config{
|
|
DefaultSampler: trace.ProbabilitySampler(sampleFraction),
|
|
MaxMessageEventsPerSpan: 500,
|
|
})
|
|
|
|
log.Infof("Starting Jaeger exporter endpoint at address = %s", endpoint)
|
|
exporter, err := jaeger.NewExporter(jaeger.Options{
|
|
CollectorEndpoint: endpoint,
|
|
Process: jaeger.Process{
|
|
ServiceName: serviceName,
|
|
Tags: []jaeger.Tag{
|
|
jaeger.StringTag("process_name", processName),
|
|
jaeger.StringTag("version", version.Version()),
|
|
},
|
|
},
|
|
BufferMaxCount: 10000,
|
|
OnError: func(err error) {
|
|
log.WithError(err).Error("Failed to process span")
|
|
},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
trace.RegisterExporter(exporter)
|
|
|
|
return nil
|
|
}
|