Skip to content

Commit

Permalink
Fixup: Add once logging
Browse files Browse the repository at this point in the history
  • Loading branch information
fishy committed Oct 8, 2024
1 parent f2e6a2d commit 0b11867
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 6 additions & 1 deletion httpbp/client_middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ func MaxConcurrency(maxConcurrency int64) ClientMiddleware {
}
}

var monitorClientLoggingOnce sync.Once

// MonitorClient is an HTTP client middleware that wraps HTTP requests in a
// client span.
//
Expand All @@ -272,7 +274,10 @@ func MonitorClient(slug string) ClientMiddleware {
return mw
}
return func(next http.RoundTripper) http.RoundTripper {
// no-op
// no-op but log for once
monitorClientLoggingOnce.Do(func() {
slog.Warn("httpbp.MonitorClient: internalv2compat.V2TracingHTTPClientMiddleware() returned nil")
})
return next
}
}
Expand Down
9 changes: 8 additions & 1 deletion thriftbp/client_middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package thriftbp
import (
"context"
"errors"
"log/slog"
"strconv"
"sync"
"time"

"github.com/apache/thrift/lib/go/thrift"
Expand Down Expand Up @@ -186,6 +188,8 @@ type MonitorClientArgs struct {
ErrorSpanSuppressor errorsbp.Suppressor
}

var monitorClientLoggingOnce sync.Once

// MonitorClient is a ClientMiddleware that wraps the inner thrift.TClient.Call
// in a thrift client span.
//
Expand All @@ -196,7 +200,10 @@ func MonitorClient(args MonitorClientArgs) thrift.ClientMiddleware {
return mw
}
return func(next thrift.TClient) thrift.TClient {
// no-op
// no-op but log for once
monitorClientLoggingOnce.Do(func() {
slog.Warn("thriftbp.MonitorClient: internalv2compat.V2TracingThriftClientMiddleware() returned nil")
})
return next
}
}
Expand Down
9 changes: 8 additions & 1 deletion thriftbp/server_middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"errors"
"fmt"
"log/slog"
"strconv"
"sync"
"time"

"github.com/apache/thrift/lib/go/thrift"
Expand Down Expand Up @@ -126,6 +128,8 @@ func wrapErrorForServerSpan(err error, suppressor errorsbp.Suppressor) error {
return thriftint.WrapBaseplateError(suppressor.Wrap(err))
}

var injectServerSpanLoggingOnce sync.Once

// InjectServerSpan implements thrift.ProcessorMiddleware and injects a server
// span into the `next` context.
//
Expand All @@ -136,7 +140,10 @@ func InjectServerSpan(_ errorsbp.Suppressor) thrift.ProcessorMiddleware {
return mw
}
return func(name string, next thrift.TProcessorFunction) thrift.TProcessorFunction {
// no-op
// no-op but log for once
injectServerSpanLoggingOnce.Do(func() {
slog.Warn("thriftbp.InjectServerSpan: internalv2compat.V2TracingThriftServerMiddleware() returned nil")
})
return next
}
}
Expand Down

0 comments on commit 0b11867

Please sign in to comment.