Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
PIP-2329: Adjust tracing detail. (#166)
Browse files Browse the repository at this point in the history
Co-authored-by: Shawn Poulson <[email protected]>
  • Loading branch information
Baliedge and Baliedge authored Mar 1, 2023
1 parent f888586 commit 30437ac
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion cmd/gubernator-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func main() {
tracing.EndScope(startCtx, nil)

var client guber.V1Client
err = tracing.Scope(ctx, func(ctx context.Context) error {
err = tracing.CallScope(ctx, func(ctx context.Context) error {
// Print startup message.
cmdLine := strings.Join(os.Args[1:], " ")
logrus.WithContext(ctx).Info("Command line: " + cmdLine)
Expand Down
2 changes: 1 addition & 1 deletion daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type Daemon struct {
func SpawnDaemon(ctx context.Context, conf DaemonConfig) (*Daemon, error) {
var s *Daemon

err := tracing.Scope(ctx, func(ctx context.Context) error {
err := tracing.CallScope(ctx, func(ctx context.Context) error {
s = &Daemon{
log: conf.Logger,
conf: conf,
Expand Down
4 changes: 2 additions & 2 deletions global.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (gm *globalManager) runAsyncHits() {
hits := make(map[string]*RateLimitReq)

gm.wg.Until(func(done chan struct{}) bool {
ctx := tracing.StartScope(context.Background())
ctx := tracing.StartScopeDebug(context.Background())
defer tracing.EndScope(ctx, nil)

select {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (gm *globalManager) runBroadcasts() {
updates := make(map[string]*RateLimitReq)

gm.wg.Until(func(done chan struct{}) bool {
ctx := tracing.StartScope(context.Background())
ctx := tracing.StartScopeDebug(context.Background())
defer tracing.EndScope(ctx, nil)

select {
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3
github.com/hashicorp/memberlist v0.5.0
github.com/mailgun/holster/v4 v4.11.1
github.com/mailgun/holster/v4 v4.12.0
github.com/miekg/dns v1.1.50
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.37.0
github.com/segmentio/fasthash v1.0.2
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.2
go.etcd.io/etcd/client/v3 v3.5.5
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.39.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.39.0
Expand All @@ -25,8 +25,8 @@ require (
golang.org/x/net v0.7.0
golang.org/x/time v0.3.0
google.golang.org/api v0.108.0
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44
google.golang.org/grpc v1.53.0
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2
google.golang.org/grpc v1.52.3
google.golang.org/protobuf v1.28.1
k8s.io/api v0.23.3
k8s.io/apimachinery v0.23.3
Expand Down Expand Up @@ -81,7 +81,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.13.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.13.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.13.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.13.0 // indirect
go.opentelemetry.io/otel/metric v0.36.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
Expand Down
19 changes: 10 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailgun/holster/v4 v4.11.1 h1:blr4a4DPtsi3jZF7aHaxBtmvw7YU5SNG6MJbGto5pZM=
github.com/mailgun/holster/v4 v4.11.1/go.mod h1:sXpF+rzEqA89uBEiX19FrVUdbCUKDfR4GRdXmIkINQQ=
github.com/mailgun/holster/v4 v4.12.0 h1:SsorK7fkIdkyW7pE1Vg4aCXWiwZEz15cf8FT31IPlZU=
github.com/mailgun/holster/v4 v4.12.0/go.mod h1:s2H6HX3iMCub1K1Y7qjf0RgpzS2+mRxyj+i3vlb4FK0=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
Expand Down Expand Up @@ -413,8 +413,9 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/uptrace/opentelemetry-go-extra/otellogrus v0.1.21 h1:OXsouNDvuET5o1A4uvoCnAXuuNke8JlfZWceciyUlC8=
github.com/uptrace/opentelemetry-go-extra/otellogrus v0.1.21/go.mod h1:Xm3wlRGm5xzdAGPOvqydXPiGj0Da1q0OlUNm7Utoda4=
Expand Down Expand Up @@ -454,8 +455,8 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.13.0 h1:Any/nVxaoMq1T2w0W85
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.13.0/go.mod h1:46vAP6RWfNn7EKov73l5KBFlNxz8kYlxR1woU+bJ4ZY=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.13.0 h1:Wz7UQn7/eIqZVDJbuNEM6PmqeA71cWXrWcXekP5HZgU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.13.0/go.mod h1:OhH1xvgA5jZW2M/S4PcvtDlFE1VULRRBsibBrKuJQGI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2 h1:Us8tbCmuN16zAnK5TC69AtODLycKbwnskQzaB6DfFhc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2/go.mod h1:GZWSQQky8AgdJj50r1KJm8oiQiIPaAX7uZCFQX9GzC8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.13.0 h1:Ntu7izEOIRHEgQNjbGc7j3eNtYMAiZfElJJ4JiiRDH4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.13.0/go.mod h1:wZ9SAjm2sjw3vStBhlCfMZWZusyOQrwrHOFo00jyMC4=
go.opentelemetry.io/otel/metric v0.36.0 h1:t0lgGI+L68QWt3QtOIlqM9gXoxqxWLhZ3R/e5oOAY0Q=
go.opentelemetry.io/otel/metric v0.36.0/go.mod h1:wKVw57sd2HdSZAzyfOM9gTqqE8v7CbqWsYL6AyrH9qk=
go.opentelemetry.io/otel/sdk v1.13.0 h1:BHib5g8MvdqS65yo2vV1s6Le42Hm6rrw08qU6yz5JaM=
Expand Down Expand Up @@ -819,8 +820,8 @@ google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 h1:EfLuoKW5WfkgVdDy7dTK8qSbH37AX5mj/MFh+bGPz14=
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA=
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2 h1:O97sLx/Xmb/KIZHB/2/BzofxBs5QmmR0LcihPtllmbc=
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand All @@ -844,8 +845,8 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/grpc v1.52.3 h1:pf7sOysg4LdgBqduXveGKrcEwbStiK2rtfghdzlUYDQ=
google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
2 changes: 1 addition & 1 deletion gubernator.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var batchSendDurationMetric = prometheus.NewSummaryVec(prometheus.SummaryOpts{
// NewV1Instance instantiate a single instance of a gubernator peer and registers this
// instance with the provided GRPCServer.
func NewV1Instance(conf Config) (retval *V1Instance, reterr error) {
ctx := tracing.StartScope(context.Background())
ctx := tracing.StartScopeDebug(context.Background())
defer func() {
tracing.EndScope(ctx, reterr)
}()
Expand Down
8 changes: 4 additions & 4 deletions gubernator_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ mainloop:
}

func (chp *GubernatorPool) handleLoad(request poolLoadRequest, cache Cache) {
ctx := tracing.StartScope(request.ctx)
ctx := tracing.StartScopeDebug(request.ctx)
defer tracing.EndScope(ctx, nil)

mainloop:
Expand Down Expand Up @@ -531,7 +531,7 @@ func (chp *GubernatorPool) Store(ctx context.Context) (reterr error) {
}

func (chp *GubernatorPool) handleStore(request poolStoreRequest, cache Cache) {
ctx := tracing.StartScope(request.ctx)
ctx := tracing.StartScopeDebug(request.ctx)
defer tracing.EndScope(ctx, nil)

for item := range cache.Each() {
Expand Down Expand Up @@ -595,7 +595,7 @@ func (chp *GubernatorPool) AddCacheItem(ctx context.Context, key string, item *C
}

func (chp *GubernatorPool) handleAddCacheItem(request poolAddCacheItemRequest, cache Cache) {
ctx := tracing.StartScope(request.ctx)
ctx := tracing.StartScopeDebug(request.ctx)
defer tracing.EndScope(ctx, nil)

exists := cache.Add(request.item)
Expand Down Expand Up @@ -648,7 +648,7 @@ func (chp *GubernatorPool) GetCacheItem(ctx context.Context, key string) (item *
}

func (chp *GubernatorPool) handleGetCacheItem(request poolGetCacheItemRequest, cache Cache) {
ctx := tracing.StartScope(request.ctx)
ctx := tracing.StartScopeDebug(request.ctx)
defer tracing.EndScope(ctx, nil)

item, ok := cache.GetItem(request.key)
Expand Down
6 changes: 3 additions & 3 deletions peer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (c *PeerClient) run() {
return
}

_ = tracing.ScopeDebug(r.ctx, func(reqCtx context.Context) error {
_ = tracing.CallNamedScope(r.ctx, "Send batch", func(reqCtx context.Context) error {
span := trace.SpanFromContext(reqCtx)
span.SetAttributes(
attribute.String("peer.grpcAddress", c.conf.Info.GRPCAddress),
Expand Down Expand Up @@ -438,7 +438,7 @@ func (c *PeerClient) run() {
queue = nil

go func() {
ctx2 := tracing.StartScope(ctx)
ctx2 := tracing.StartNamedScope(ctx, "Send batch")
defer tracing.EndScope(ctx2, nil)
intervalSpan := trace.SpanFromContext(ctx2)
intervalSpan.SetAttributes(
Expand All @@ -455,7 +455,7 @@ func (c *PeerClient) run() {
// sendQueue sends the queue provided and returns the responses to
// waiting go routines
func (c *PeerClient) sendQueue(ctx context.Context, queue []*request) {
ctx = tracing.StartScope(ctx)
ctx = tracing.StartScopeDebug(ctx)
defer tracing.EndScope(ctx, nil)
span := trace.SpanFromContext(ctx)
span.SetAttributes(
Expand Down

0 comments on commit 30437ac

Please sign in to comment.