Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: config.Configuration.InitGlobalTracer panics if http.DefaultTransport is not a *http.Transport #616

Open
colega opened this issue Dec 18, 2023 · 0 comments
Labels

Comments

@colega
Copy link

colega commented Dec 18, 2023

What happened?

I called config.Configuration.InitGlobalTracer(...) after replacing the http.DefaultTransport with a custom implementation, and it panicked.

The code assumes that http.DefaultTransport is a *http.Transport, and panics otherwise:

customTransport := http.DefaultTransport.(*http.Transport).Clone()

Steps to reproduce

  1. Replace http.DefaultTransport value in your app.
  2. Call config.Configuration.InitGlobalTracer()

Example: https://go.dev/play/p/TH-uFyyMuLD

package main

import (
	"fmt"
	"net/http"

	"github.com/uber/jaeger-client-go/config"
)

func main() {
	http.DefaultTransport = &customTransport{&http.Transport{}}
	closer, err := config.Configuration{}.InitGlobalTracer("hello-world")
	if err != nil {
		panic(fmt.Errorf("failed: %w", err))
	}
	defer closer.Close()

	fmt.Println("Hello, 世界")
}

type customTransport struct {
	next http.RoundTripper
}

func (ct *customTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	return ct.next.RoundTrip(req)
}

Expected behavior

It shouldn't panic.

Relevant log output

No response

Screenshot

No response

Additional context

No response

Jaeger backend version

No response

SDK

No response

Pipeline

No response

Stogage backend

No response

Operating system

No response

Deployment model

No response

Deployment configs

No response

@colega colega added the bug label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant