Skip to content

Commit

Permalink
Rename Jaeger round tripper
Browse files Browse the repository at this point in the history
  • Loading branch information
monstermunchkin committed Sep 3, 2024
1 parent b4976a3 commit b7c27b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/couchdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func Client(cfg *Config) (*kivik.Client, error) {
Username: cfg.User,
Password: cfg.Password,
},
&transport.JaegerRoundTripper{},
&transport.TracingRoundTripper{},
transport.NewDumpRoundTripperEnv(),
}
if !cfg.DisableRequestLogging {
Expand Down
4 changes: 2 additions & 2 deletions http/transport/default_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewDefaultTransportChain() *RoundTripperChain {
return Chain(
&ExternalDependencyRoundTripper{},
NewDefaultRetryRoundTripper(),
&JaegerRoundTripper{},
&TracingRoundTripper{},
&LoggingRoundTripper{},
&LocaleRoundTripper{},
&RequestIDRoundTripper{},
Expand All @@ -24,7 +24,7 @@ func NewDefaultTransportChainWithExternalName(name string) *RoundTripperChain {
return Chain(
&ExternalDependencyRoundTripper{name: name},
NewDefaultRetryRoundTripper(),
&JaegerRoundTripper{},
&TracingRoundTripper{},
&LoggingRoundTripper{},
&LocaleRoundTripper{},
&RequestIDRoundTripper{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import (
"github.com/getsentry/sentry-go"
)

// JaegerRoundTripper implements a chainable round tripper for tracing
type JaegerRoundTripper struct {
// TracingRoundTripper implements a chainable round tripper for tracing
type TracingRoundTripper struct {
transport http.RoundTripper
}

// Transport returns the RoundTripper to make HTTP requests
func (l *JaegerRoundTripper) Transport() http.RoundTripper {
func (l *TracingRoundTripper) Transport() http.RoundTripper {
return l.transport
}

// SetTransport sets the RoundTripper to make HTTP requests
func (l *JaegerRoundTripper) SetTransport(rt http.RoundTripper) {
func (l *TracingRoundTripper) SetTransport(rt http.RoundTripper) {
l.transport = rt
}

// RoundTrip executes a HTTP request with distributed tracing
func (l *JaegerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
func (l *TracingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
ctx := req.Context()

span := sentry.StartTransaction(ctx, fmt.Sprintf("%s %s", req.Method, req.URL.Path))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (
"github.com/stretchr/testify/require"
)

func TestJaegerRoundTripper(t *testing.T) {
func TestTracingRoundTripper(t *testing.T) {
err := sentry.Init(sentry.ClientOptions{
EnableTracing: true,
TracesSampleRate: 1.0,
})
require.NoError(t, err)

t.Run("With successful response", func(t *testing.T) {
l := &JaegerRoundTripper{}
l := &TracingRoundTripper{}
tr := &recordingTransportWithResponse{statusCode: 202}
l.SetTransport(tr)

Expand All @@ -44,7 +44,7 @@ func TestJaegerRoundTripper(t *testing.T) {
})

t.Run("With error response", func(t *testing.T) {
l := &JaegerRoundTripper{}
l := &TracingRoundTripper{}
e := errors.New("some error")
tr := &recordingTransportWithError{err: e}
l.SetTransport(tr)
Expand All @@ -62,7 +62,7 @@ func TestJaegerRoundTripper(t *testing.T) {

t.Run("With retries", func(t *testing.T) {
tr := &retriedTransport{statusCodes: []int{502, 503, 200}}
l := Chain(NewDefaultRetryRoundTripper(), &JaegerRoundTripper{})
l := Chain(NewDefaultRetryRoundTripper(), &TracingRoundTripper{})
l.Final(tr)

req := httptest.NewRequest("GET", "/bar", nil)
Expand Down

0 comments on commit b7c27b7

Please sign in to comment.